I’m writing my first Rails app and I’m stuck at the database level. I
have
2 models: User and Mission. They are connected very unremarkably like
so:
User has_many :missions, dependent: :destroy
Mission belongs_to :user
I would like other users to be able to interact with missions by either:
liking
them and/or marking them as completed
This is all very vanilla stuff here, but I’m struggling with adding this
additional layer of interaction into the models.
I started by creating a table Connection with attributes user_id
mission_id
liked:booleancompleted:boolean
I added the following:
User has_many :connections, dependent: :destroy
Connection belongs_to :user
Connection belongs_to :mission
Do I need a has_many :through relationship? I’m trying to preserve the
ownership between a User and a Mission ( belongs_to association ). I’m
reading about polymorphic associations and am wondering if they are
applicable? Any help would be greatly appreciated. Thanks!