When using with Rails, nil is being sent to partials, causing "ActionView::Template::Error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id " #71

Closed
xxx opened this Issue Oct 10, 2012 · 3 comments

Projects

None yet

5 participants

@xxx
xxx commented Oct 10, 2012

This is easier to show than describe, but after updating Jbuilder from 0.4.3 to 0.8.2, we are seeing errors where an instance variable that's being used in a template tries to render partials, even when it's nil.

I'm unable to repeat this issue with straight Jbuilder - it's only happening when used with Rails as far as I can tell, so this may need to be fixed on the Rails side. Jbuilder is the only thing I'm changing to cause these, however.

I will try to come up with a broken example app later, but I'm stuck in meetings for awhile and wanted to report this before I forgot.

Example:

# user.json.jbuilder
json.(@user, :id, :name)

# @friends is nil
json.friends @friends do |json, friend|
  json.partial! :partial => 'users/friend', :locals => {:friend => friend}
end


# _friend.json.jbuilder
json.(friend, :id, :name)
@mikecx
mikecx commented Oct 23, 2012

+1

@maletor
maletor commented Dec 20, 2012

Seeing this too...

@rwz
Collaborator
rwz commented Dec 29, 2012

Fixed by 780e047

@dhh dhh closed this Dec 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment