Forum: Ruby on Rails Object#id being deprecated - Rails 1.1

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7fc62c7ce136d50a68b13beb00765218?d=identicon&s=25 Piers Young (Guest)
on 2006-03-21 14:15
Hi

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"

l.8 is <%= link_to 'Bookmark this', :action => 'bookmark', :id =>
@item.id %>

From http://corelib.rubyonrails.org/classes/Object.html#M001093 etc, I
can see that the @item.id is throwing the error, and that  @item.item_id
just gives me a no method error.

Any help would be great, if people have time.

Thanks

Piers
6e09635022712a6dd26b9510a2c96820?d=identicon&s=25 Pazu (Guest)
on 2006-03-21 14:24
(Received via mailing list)
Piers Young <piers.young@...> writes:

> >From http://corelib.rubyonrails.org/classes/Object.html#M001093 etc, I
> can see that the  <at> item.id is throwing the error, and that   <at>
item.item_id
> just gives me a no method error.


Hmm... I know it sounds obvious, but have you tried @item.object_id?

-- Pazu
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-03-21 14:37
(Received via mailing list)
Piers Young wrote:
> "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.
7fc62c7ce136d50a68b13beb00765218?d=identicon&s=25 Piers (Guest)
on 2006-03-21 14:52
> Hmm... I know it sounds obvious, but have you tried @item.object_id?
>
> -- Pazu

Thanks Pazu - worked a treat.
Feeling very silly

Piers
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-03-21 17:41
(Received via mailing list)
On Mar 21, 2006, at 5:52 AM, Piers wrote:

>> Hmm... I know it sounds obvious, but have you tried @item.object_id?
>>
>> -- Pazu
>
> Thanks Pazu - worked a treat.
> Feeling very silly

I'm finding it hard to believe that's the solution you're looking for.

--
-- Tom Mornini
8a456610e31c8feadc4cef71d9347cbd?d=identicon&s=25 Craig Ambrose (Guest)
on 2006-03-22 01:07
(Received via mailing list)
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:

<%= link_to 'Bookmark this', :action => 'bookmark', :id => @item %>

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 topic is locked and can not be replied to.