ボルトモデルに型制限を設定したい
class EventItemBlock < Volt::Model
:name, String
:items, Volt::ArrayModel
end
ファイルを保存すると、Volt はバックグラウンドでエラーをスローしますが、クラッシュしません。関連する行は最初の 7 行で、コンマが構文エラーであることを示しています。
Volt Framework のドキュメントでは、コンマは適切な構文として記載されています ( http://docs.voltframework.com/en/docs/models.html )。カンマを削除してもエラーは解決されません。タイプの制限を削除するだけで解決します。
[ERROR] #<SyntaxError: /home/jg/ModelTest/app/main/models/event_item_block.rb:2: syntax error, unexpected ',', expecting keyword_end
:name, String
^
/home/jg/ModelTest/app/main/models/event_item_block.rb:3: syntax error, unexpected ',', expecting keyword_end
:items, Volt::ArrayModel
^>
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:67:in `require'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:67:in `block (2 levels) in require_in_components'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:65:in `each'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:65:in `block in require_in_components'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:31:in `block in app_folders'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:30:in `each'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:30:in `app_folders'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/rack/component_paths.rb:61:in `require_in_components'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/volt/server_setup/app.rb:16:in `setup_paths'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/volt/app.rb:74:in `initialize'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/boot.rb:21:in `new'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/boot.rb:21:in `boot'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server.rb:44:in `boot_volt'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/forking_server.rb:73:in `start_child'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/forking_server.rb:229:in `block in reload'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/utils/read_write_lock.rb:65:in `with_write_lock'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/forking_server.rb:227:in `reload'
/home/jg/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/volt-0.9.4/lib/volt/server/forking_server.rb:239:in `block (2 levels) in start_change_listener'