I''ve been looking on the internet for the feature in rails where you can specify an association extend module on the actual class. So for example class Printer < AR::Base some_association_extend_method_that_i_cant_figure_out do def [](value) find_by_name(value) end end end class Product < AR::Base has_many :printers end product.printers["name"] # <-- should return the printer if it exists Product["name"] # <-- should work as well. Does anyone know what im talking about? I saw it once, I can''t find it again. -- 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 -~----------~----~----~----~------~----~------~--~---
On Sep 13, 4:53 am, Aryk Grosz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''ve been looking on the internet for the feature in rails where you can > specify an association extend module on the actual class. > > So for example > > class Printer < AR::Base > some_association_extend_method_that_i_cant_figure_out do > def [](value) > find_by_name(value) > end > end > end > class Product < AR::Base > has_many :printers > end > > product.printers["name"] # <-- should return the printer if it exists > Product["name"] # <-- should work as well. > > Does anyone know what im talking about? I saw it once, I can''t find it > again. > -- > Posted viahttp://www.ruby-forum.com/.Maybe you''re looking for has_finder or, in Rails 2.1, named_scope. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
yes thats what i was looking for. thx. -- 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 -~----------~----~----~----~------~----~------~--~---