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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---