Hey all ! I tried using both this methods on rails edge and got method missing , looked for them in a model.methds in "script/console" but no luck ... Anyone can help !? Regards --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi,> I tried using both this methods on rails edge and got method missing , > looked for them in a model.methds in "script/console" but no luck ... >you will not see those methods by using .methods on a new object since the methods are dynamically created. Notice you can have a *huge* number of combinations if you have a table with some fields, and Active Record is not going to create every single of the possible methods for you unless you are going to use them. Suppose you are trying to execute Model.find_all_by_size_and_color_and_model_and_material. Since that method is undefined, method_missing will be invoked for your class, and ActiveRecord will make "the magic" at that moment. It will check if the signature of the method makes sense with the attributes for that particular model, and if it does, it will execute the find for you. Moreover, since ruby is dynamic, AR will define a method with that signature on the fly for this class, so next time you call it you will save all the process of hitting method_missing and so on. This means you will not be able to see the method by invoking .methods until you execute a find and it gets dynamically defined. regards, javier ramirez --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Uh got it ... more method_missisng Ruby Magic ! :) Silly stupid me ! :) Thanks ! On Oct 4, 11:46 am, javier ramirez <jrami...-7iWCczGtl7hBDgjK7y7TUQ@public.gmane.org> wrote:> Hi, > > > I tried using both this methods on rails edge and got method missing , > > looked for them in a model.methds in "script/console" but no luck ... > > you will not see those methods by using .methods on a new object since > the methods are dynamically created. Notice you can have a *huge* number > of combinations if you have a table with some fields, and Active Record > is not going to create every single of the possible methods for you > unless you are going to use them. > > Suppose you are trying to execute > Model.find_all_by_size_and_color_and_model_and_material. Since that > method is undefined, method_missing will be invoked for your class, and > ActiveRecord will make "the magic" at that moment. It will check if the > signature of the method makes sense with the attributes for that > particular model, and if it does, it will execute the find for you. > Moreover, since ruby is dynamic, AR will define a method with that > signature on the fly for this class, so next time you call it you will > save all the process of hitting method_missing and so on. > > This means you will not be able to see the method by invoking .methods > until you execute a find and it gets dynamically defined. > > regards, > > javier ramirez--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---