Think this is probably straightforward, but I don’t know enough about
rails to work it out, so was wondering if anyone can help
I keep on running into this error when I’m deploying my app:
“FastCGI: server “…/public_html/public/dispatch.fcgi” stderr:
…/config/…/app/views/items/_side_share.rhtml:8: warning: Object#id
will be deprecated; use Object#object_id”
“FastCGI: server “…/public_html/public/dispatch.fcgi” stderr:
…/config/…/app/views/items/_side_share.rhtml:8: warning: Object#id
will be deprecated; use Object#object_id”
l.8 is <%= link_to ‘Bookmark this’, :action => ‘bookmark’, :id => @item.id %> @item’s probably nil. If it was an AR object, it would respond to id()
without throwing an error. nil, being an object, responds to id(), but
with exactly that warning message.
I’ve come across this same problem before, and just as Alex suggested,
it was because my active record object was nil. As well as obviously
ensuring that it isn’t nil, you could try replying you link with the
following:
Note that I’m just using @item instead of @item.id. In this case,
link_to knows to try and extract the id from @item, and it does it by
called @item.to_param, which is an active record method which defaults
to returning the id. From memory, this gives a much more graceful result
if the id is null.
regards,
Craig
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.