Open ownadi opened 10 years ago
Running into this same exact problem. This issue from JBuilder may have something to do with it?
You should update tilt-jbuilder gem to 0.7.0.
It is fixed in new version.
I'm trying json.partial! 'path_to_partial' but I'm getting ArgumentError (file or block required).
Please, show full stacktrace, bundle list
output and your template.
Do you have partial with path path_to_partial
?
Hi! Here...
ArgumentError (file or block required):
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/tilt-1.4.1/lib/tilt/template.rb:51:in `initialize'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/tilt-jbuilder-0.7.0/lib/tilt/jbuilder.rb:25:in `new'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/tilt-jbuilder-0.7.0/lib/tilt/jbuilder.rb:25:in `partial!'
/Users/katpadi/xxx/app/views/api/v1/somethings/something.jbuilder:2:in `block (3 levels) in evaluate'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:298:in `block (2 levels) in _map_collection'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:305:in `_scope'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:298:in `block in _map_collection'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:297:in `map'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:297:in `_map_collection'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/jbuilder-2.3.1/lib/jbuilder.rb:188:in `array!'
/Users/katpadi/.rvm/gems/ruby-2.1.2@xxx/gems/tilt-jbuilder-0.7.0/lib/tilt/jbuilder.rb:35:in `array!'
/Users/katpadi/xxx/app/views/api/v1/somethings/something.jbuilder:1:in `block (2 levels) in evaluate'
I tried in my console:
Tilt::JbuilderTemplate.new("views/some_dir/_partial.jbuilder")
and it works. I just can't use json.partial! in my jbuilder file.
I am calling it like this
json.partial! 'some_dir/partial'
I think you should check your template view_path in app and partial name in template.
Tilt just cannot find your partial
I explicitly defined view_path and it worked!
json.partial! 'some_dir/partial', view_path: Rails.root.join("app", "views", "api", "v1")
I wonder why it's not being picked up automatically?
The view_path in rails app is Rails.root.join("app", "views") if I am right.
You should set partial name from this dir, for instance:
json.partial! 'api/v1/some_dir/partial'
@ownadi @katpadi @ryanbillingsley Is everything ok? @milkcocoa Can we close this?
Hello! You can close this now. Thank you! On Dec 13, 2015 11:40 PM, "Vasiliy Yorkin" notifications@github.com wrote:
@ownadi https://github.com/ownadi @katpadi https://github.com/katpadi @ryanbillingsley https://github.com/ryanbillingsley Is everything ok? @milkcocoa https://github.com/milkcocoa Can we close this?
— Reply to this email directly or view it on GitHub https://github.com/milkcocoa/grape-jbuilder/issues/6#issuecomment-164269139 .
json.array! Item.all, partial: 'item', as: :item
throws exceptionTypeError: {:partial=>"item", :as=>:item} is not a symbol
ruby 2.1.2 rails 4.1.6