Hey.
just found out that Rails 2.0 (in the prerelease version) does not
have the extended dynamic finders
find_or_create_by_name and find_or_initialize_by_name
They are mentioned in the old 1.x docs
(section “Dynamic attribute-based finders”)
But I couldnt find it in the edge docs (http://caboo.se/doc.html)
Could somebody hint me at what to do? Did they move to a plugin?
which? Are there lines I can implement myself?
Any help appreciated,
Thanks!
/Jesper
They’re still there. Check out method_missing on ActiveRecord::Base.
RSL
Thx Russel.
But how come that it does not work. I get this error printed below.
What can I do to make it work with the current pre-release?
/Jesper
=========
PoliceJournal.find_or_initialize_by_name(“hello”)
NoMethodError: undefined method find_or_initialize_by_name' for #<Class:0x48fc90c> from C:/Documents and Settings/Administrator/My Documents/ rails/project/vendor/rails/activerecord/lib/active_recor d/base.rb:1277:in
method_missing’
from (irb):1
DOH.
Sorry. found out that my model PoliceJournal did not have “name” I
should have used
PoliceJournal.find_or_initialize_by_number
DOH.
Sorry to have interrupted you.