From: Mike Fletcher Date: 2005-12-06T04:24:40+09:00 Subject: Re: a todo list fletch wrote: > However the original code: > >> <%= link_to("Edit", :action => "edit", :id => @tasklists.id) %> > > *is* calling Object#id via an Array instance rather than letting AR do > it's magic. That's why there's a value for id, and also why it's a > useless value. Had he done ":id => @tasklists" instead there wouldn't > have been an id value on the end (pointing at ".../tasklist/edit/" > instead of ".../tasklist/edit/29134536" like it did) and he would have > had a different problem (depending on how his edit action handles a > missing id as opposed to an invalid one). If you try code like the original: <%= link_to 'Test on AR instance', :action => 'show', :id => @foo %>
<%= link_to 'Test on Array instance', :action => 'show', :id => Array.new() %>
<%= link_to 'Test on Array w/id', :action => 'show', :id => Array.new().id %> You'll see the difference in the anchors produced: Test on AR instance
Test on Array instance
Test on Array w/id And you do get the deprecation warning for the last one (from the output of script/server in this case): ./script/../config/../app/views/test/show.rhtml:6: warning: Object#id will be deprecated; use Object#object_id -- Posted via http://www.ruby-forum.com/.