I am back to working with additional fields in a HABTM and going to try the method as described in the cookbook.
"Child hasMany Membership
Membership belongsTo Child, Club
Club hasMany Membership."
Membership belongsTo Child, Club
Club hasMany Membership."
In my setup I have User, Skill, Year, Skillset and UsersSkill but not sure of setting up the relationship properly. (no HABTM relations in the site anymore)
Year = the years to select from (0 -6 months, 1-5 years....so on)
Skill = the available options of skills to select from (Math, Gym,History....)
Skillset = simply groups the Skill into a category (Educational, Extra Cirricular.....)(Skillset also allows me to pull skills specific to Skill thats why I added that in so rather than having a table for educational, extra_curricualr and all the other sets I just grouped them in 1 table)
UsersSkill = user_id, skill_id, skillst_id, year_id (this holds all of the Users skills)
So basicaly i render a form that has all the Skill options name with a dropdown of Years to select beside each Skill so if a User selects 0 -6 months beside Gym they are saying thy have taught Gym for 0-6 months.
Gym [year dropdown]
Math [year dropdown]
History [year dropdown]
So in UsersSkills the user_id, skill_id, year_id and the skillset_id get saved
But not sure if i have the relations correct. When i go to edit / add a user i am getting Skills by User->UsersSkill->Skill.
Should it be like?
User hasMany Skill
Skill belongsTo User, Skillset
Skillset belongsTo User
Skillset hasMany User
Skillset hasMany Year
Skillset hasMany Skill
But where does UsersSkill fit in? Completely confused.
can someone explain the correct way or where i have gone wrong.
Thanks
Dave
No comments:
Post a Comment