A Group
can have many keywords and a Keyword
can have many groups. I have this relationship defined as
class Keyword < ActiveRecord::Base
has_many :groups_keywords
has_many :groups, through: :groups_keywords
end
class GroupsKeyword < ActiveRecord::Base
belongs_to :groups
belongs_to :keywords
end
class Group < ActiveRecord::Base
has_many :groups_keywords
has_many :keywords, through: :groups_keywords
end
I can do Group.find(1).groups_keywords
so the relationship is working?
But I want to get all of my Groups
keywords so I do the following.
Group.find(1).keywords
But I get the error uninitialized constant Group::Keywords
Aucun commentaire:
Enregistrer un commentaire