On Tue, Nov 25, 2008 at 2:04 PM, s.ross <[EMAIL PROTECTED]> wrote: > In Rails, the primary key, by default 'id', is used all over the > place. However, Ruby now deprecates the use of constructs like: > > @post = Post.find(:first) > @post_id = @post.id
I think you've got the wrong end of the stick there. Object#id (which returns a unique id for the Ruby object) was deprecated in favor of Object#object_id, mostly because ActiveRecord overrides it to return the primary key. #id seemed in retrospect too common to be reserved for an implementation detail. You *should* use model.id to get the primary key. If you're getting that warning, you're calling #id on something that doesn't decend from ActiveRecord::Base. #id is one of the few things that nil responds to (and issues the deprecation warning); maybe there are no Posts in your DB? Try checking the value of @post. Peter _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
