Jesper Rønn-Jensen
2007-Oct-19 18:48 UTC
Rails 2.0 missing find_or_create_by_name and find_or_initialize_by_name
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 http://api.rubyonrails.org/classes/ActiveRecord/Base.html (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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Oct-19 19:03 UTC
Re: Rails 2.0 missing find_or_create_by_name and find_or_initialize_by_name
They're still there. Check out method_missing on ActiveRecord::Base. :) RSL On 10/19/07, Jesper R�nn-Jensen <jesperrr@gmail.com> wrote:> > 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 http://api.rubyonrails.org/classes/ActiveRecord/Base.html > (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 > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jesper Rønn-Jensen
2007-Oct-19 20:29 UTC
Re: Rails 2.0 missing find_or_create_by_name and find_or_initialize_by_name
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jesper Rønn-Jensen
2007-Oct-19 21:03 UTC
Re: Rails 2.0 missing find_or_create_by_name and find_or_initialize_by_name
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---