Nadal
(Nadal)
1
I am using rails3 edge.
class user < AR
has_many :books
end
Following statement is failing in console.
User.first.books.find(:conditions => {:title => 'ror'})
ActiveRecord::RecordNotFound: Couldn't find Book without an ID
It is such a basic thing that I am sure can't fail.
Is it working fine for others?
Please test it with rails edge and not with beta3.
Thanks
I am using rails3 edge.
class user < AR
has_many :books
end
Following statement is failing in console.
User.first.books.find(:conditions => {:title => 'ror'})
Don't you need find(:all, :conditions....) or is that a rails 3 change?
Colin
Nadal
(Nadal)
3
No. It is not a rails3 thing. It was just me being stupid.
Can't believe I missed that. Spent so much time on this.
Thanks
Con
(Con)
4
I am using rails3 edge.
class user < AR
has_many :books
end
Following statement is failing in console.
User.first.books.find(:conditions => {:title => ‘ror’})
Nadal, the above syntax is marked for deprecation in Rails 3.1. Thus, I would recommend using the newer
interfaces. Thus, you can write the above by doing the following:
User.first.books.where( :title => ‘ror’ )
I would recommend taking a look at the following screen cast:
http://media.railscasts.com/videos/202_active_record_queries_in_rails_3.mov
Also, Pratik has an excellent post on the subject that you can find here:
http://m.onkey.org/2010/1/22/active-record-query-interface
Good luck,
-Conrad