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!

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/rj0_oOOrrV0J.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to