So, I have a somewhat confusing relationship between Note, Group and User. And I ended up with has_many twice in my model. But I'm currently focused on the Note and Group relationship.
Reference Information. The group may have a note. The user may also have a note. That is why my note is polymorphic. However, I also created a union model called a tag, so that Note can belong to several groups. In my code, however, I ended up with a few "has_many: notes". See all my code below. What would be the right way to do something like this?
Thanks in advance!
note.rb
belongs_to :notable, :polymorphic => true has_many :tags has_many :groups, :through => :tags
user.rb
has_many :notes, :as => :notable
group.rb
has_many :notes, :as => :notable has_many :tags has_many :notes, :through => :tags
tag.rb
belongs_to :note belongs_to :group
source share