Rails 2.0 missing find_or_create_by_name and find_or_initialize_by_name


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,



They’re still there. Check out method_missing on ActiveRecord::Base. :slight_smile:


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?



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:inmethod_missing’
from (irb):1

Sorry. found out that my model PoliceJournal did not have “name” I
should have used

Sorry to have interrupted you.