I have three main models that I work with:
class User < ActiveRecord::Base has_many :assignments end class Assignment < ActiveRecord::Base belongs_to :group belongs_to :user end class Group < ActiveRecord::Base has_many :assignments end
Using this scheme, I would suggest that the Destination model is a connection table that contains information for which users belong to those groups. So, what I'm trying to do using the User object, find out which groups they belong to.
In the Rail console, I do the following:
me = User.find(1)
Returns the user object, as expected. Then I try to see which “groups” this user belongs to, which, as I thought, will go through the “Destination” model. But I obviously have something wrong:
me.groups
What returns:
NoMethodError: undefined method `groups' for #<User:0x007fd5d6320c68>
How do I know which "groups" the "me" object belongs to?
Many thanks!
source share