Saturday, 31 August 2013

Rails Model user adding player to user pinboard

Rails Model user adding player to user pinboard

I'm creating a sports application which allows users to create pinboards,
as many as they like. The users can then add say their favorite player to
a specified pinboard. So for example User: Jack, creates a new pinboard
called "My favorite defenders", He can then go and find his favorite
defenders, say Kevin Garnet, and add/pin garnet to his "My favorite
defenders" Pinboard.
I have a Users model, a Pinboards Model and a Players model. I tried the
following association but didn't work as I wanted. User has_many
:pinboards has_many :pins, through: pinboards, source: :player
Pinboard belongs_to :user belongs_to :player I know a player can't have
many pinboards and a pinboard will hold many players. How can I get the
behavior i want; User creates pinboard---user adds player to pinboard.

No comments:

Post a Comment