Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting multiple values via join table using simple form
    primarykey
    data
    text
    <p>I have a quick question concerning join tables and multiple selections on a form. </p> <p>I have two models in a Rails App (4.0), one is called Skills, and the other, Opportunity. An opportunity can have many skills associated with it, and a skill can be associated with many opportunities.</p> <p>Because of that type of relationship I created a join table called Opportunity_Skills. This table just has skill_id, and opportunity_id. </p> <p>Here are my associations written out: </p> <pre><code>class Skill &lt; ActiveRecord::Base has_many :opportunity_skills has_many :opportunities, through: :opportunity_skills end class Opportunity &lt; ActiveRecord::Base has_many :opportunity_skills has_many :skills, through: :opportunity_skills accepts_nested_attributes_for :opportunity_skills end class OpportunitySkill &lt; ActiveRecord::Base belongs_to :opportunity belongs_to :skill end </code></pre> <p>I have created an opportunity 'new' page in order for users to create new opportunities. I would like users to be able to select multiple skills while creating a new opportunity. In order to make that happen I have made the Opportunity model accepted nested attributes for opportunity skills. </p> <p>I can't figure out what I need on my form (using simple form) to make all of the different options show up as check boxes (the values in the skills table). Any ideas or suggestions would be great. If I left out any information and/or just plain didn't make sense please let me know and I can provide more details. </p> <p>Thank you for the help in advance. </p> <p>Cheers,</p> <p>Graham </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload