Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ChefPosition (Executive, Sous, etc...)
- Skills (Creativity, speed, quality)
- ChefPositionSkill (chef_position_id, skill_id)
- ChefPositionSkillController < ApplicationController
- def index
- @ChefPositionSkills = Skill.where(:chef_position => params[:chef_position_id]
- render json: @ChefPositionSkills, status: status
- end
- end
- chef_positions
- * id
- * name
- * ...
- skills
- * id
- * name
- * ...
- chef_position_skills
- * id
- * chef_position_id
- * skill_id
- class ChefPosition < ApplicationRecord
- has_many :chef_position_skills
- has_many :skills, through: :chef_position_skills
- end
- class Skill < ApplicationRecord
- has_many :chef_position_skills
- has_many :chef_positions, through: :chef_position_skills
- end
- class ChefPositionSkill < ApplicationRecord
- belongs_to :chef_position
- belongs_to :skill
- end
- resources :chef_positions, only: [] do
- resources :chef_position_skills, only: [:index]
- end
- class ChefPositionSkillsController < ApplicationController
- def index
- chef_position = ChefPosition.find(params[:chef_position_id])
- render json: chef_position.chef_position_skills
- end
- end
Add Comment
Please, Sign In to add comment