Hi, I am doing some examples in a book on Roby on Rails. When a model class is create with generate model command, it will create some find_xxx methods on the fields. When the model have the relationships with other models, the more find_xxx methods will be generated. How do I know exactly how many and what kinds of find_xxx methods are created? Thanks. Leon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sun, Apr 5, 2009 at 6:50 PM, Leon <leon5wu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am doing some examples in a book on Roby on Rails. When a model > class is create with generate model command, it will create some > find_xxx methods on the fields. When the model have the relationships > with other models, the more find_xxx methods will be generated. How do > I know exactly how many and what kinds of find_xxx methods are > created?The API docs explain all of these added methods here: http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could also check out the guides at: http://guides.rubyonrails.org/active_record_querying.html#dynamic-finders On Apr 5, 1:50 pm, Leon <leon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I am doing some examples in a book on Roby on Rails. When a model > class is create with generate model command, it will create some > find_xxx methods on the fields. When the model have the relationships > with other models, the more find_xxx methods will be generated. How do > I know exactly how many and what kinds of find_xxx methods are > created? > > Thanks. > > Leon--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Leon wrote:> Hi, > > I am doing some examples in a book on Roby on Rails. When a model > class is create with generate model command, it will create some > find_xxx methods on the fields. When the model have the relationships > with other models, the more find_xxx methods will be generated. How do > I know exactly how many and what kinds of find_xxx methods are > created?Realizing the links provided by Greg and Rick will contain the answers you need, I wanted to make it clear that the precise answer to this question is zero. I mean that none of these methods get created when the model is created nor when relationships are defined. These methods you''re referring to are called dynamic finders because they do not exist until they are actually used at run time. The first time they are used at runtime the method won''t be found so Ruby will call it''s method_missing method. ActiveRecord''s version of method_missing dynamically adds the requested method as long as it follow the naming convention and contains appropriate arguments to satisfy the new method. Subsequent calls to the same method will use the dynamically generated one bypassing the need to call method_missing. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---