Description
Hi,
I noticed two errors in the reporting of errors with jbuilder partials rendered from a view.
The first is weird but not a big deal, the second is really problematic for debugging.
I have a view and two partials.
In views/application/home.html.haml
, I have:
- json = render(partial: 'users/user', formats: [:json], locals: { user: @user })
= javascript_tag { "window.data = {}; window.data = #{raw(json)};" }
In views/users/_user.html.haml
, I have:
= user.undefined_method_called_from_haml_template
In views/users/_user.json.jbuilder
, I have:
json.name user.undefined_method_called_from_jbuilder_template
Displaying the page raises:
NoMethodError in Application#home
Showing ~/MyTest/app/views/users/_user.html.haml where line # raised:
undefined method `undefined_method_called_from_jbuilder_template' for #User:0x007fb2bea96de8
The reported file is wrong: it should be the JSON version.
So now, the second error is visible when there is no other version of the same partial (in my case, by removing _user.html.haml
).
ActionView::MissingTemplate in Application#data
Showing ~/MyTest/app/views/application/home.html.haml where line #1 raised:
Missing partial users/user with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :jbuilder, :coffee, :haml]}.
What the hell? Why does any errors occurring in the partial are ignored and reported as a missing template (plus, the formats
and handlers
are not correct?
If I fix the error (not easy with this weird report) in the template, it works!
Any idea?