# Object#id being deprecated - Rails 1.1

**URL:** <https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470>\
**Category:** Rails\
**Created:** [March 21, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470 "2006-03-21T14:15:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 21, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/1 "2006-03-21T14:15:42Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 21, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/2 "2006-03-21T14:24:08Z")

</div>

Piers Y. \<piers.young@…\> writes:

> > From [http://corelib.rubyonrails.org/classes/Object.html#M001093](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.

Hmm… I know it sounds obvious, but have you tried @item.object\_id?

– Pazu

---

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 21, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/3 "2006-03-21T14:37:27Z")

</div>

Piers Y. 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.

---

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 21, 2006, 2:52pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/4 "2006-03-21T14:52:04Z")

</div>

> Hmm… I know it sounds obvious, but have you tried @item.object\_id?
> 
> – Pazu

Thanks Pazu - worked a treat.  
Feeling very silly

Piers

---

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 21, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/5 "2006-03-21T17:41:39Z")

</div>

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 M.

---

<div class="post-metadata">

**Author:** ![piers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b3f665/32.png) [@piers](https://www.ruby-forum.com/u/piers)\
**Post date:** [March 22, 2006, 1:07am UTC](https://www.ruby-forum.com/t/object-id-being-deprecated-rails-1-1/55470/6 "2006-03-22T01:07:57Z")

</div>

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
