Hello,
I'm getting an "NoMethodError" traversing a named collection. Let me explain
I have a named collection called best_friend in a class called user
def self.best_friend find :all, :conditions => "designation = 'Best Friend'" end
and if i do current_user.best_friend everything works great, I can
pull up the user's name as an example. My user model has a one-to-many relationship with interests. If I do
current_user.best_friend.interests however it gives a no method error.
Of course: your best_friend method returns an array (bit odd that a
method return a collection is a singular). That array doesn't have an
interests method, though its members do.
ALso from the code you've posted you've made best_friend a class
method rather than an instance method.
Finally, why not use an association for this?
Fred