Displaying 1 result from an estimated 1 matches for "products_without_root".
2009 Mar 16
4
Overriding ActiveRecord associations for special cases
...ucts.all'' instead of ''user.products''. Ideally I guess I want
to return a proxy object that represents all products. Any ideas?
class User
has_many :products
def root?
id == 1
end
def products_with_root
if root?
Product # Better way?
else
products_without_root
end
end
alias_method_chain :products, :root
end
Best regards,
Andrew France
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrail...