Skip to content

Instantly share code, notes, and snippets.

@joshsmith
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshsmith/dcd539d3a036661617c6 to your computer and use it in GitHub Desktop.
Save joshsmith/dcd539d3a036661617c6 to your computer and use it in GitHub Desktop.
class Recipe < ActiveRecord::Base
has_many :recipe_skills
has_many :skills, through: :recipe_skills
end
class Skill < ActiveRecord::Base
has_many :recipe_skills
has_many :recipes, through: :recipe_skills
end
class RecipeSkill < ActiveRecord::Base
belongs_to :recipe
belongs_to :skill
end
class User < ActiveRecord::Base
has_many :user_skills
has_many :skills, through: :user_skills
end
class UserSkill < ActiveRecord::Base
belongs_to :user
belongs_to :skill
# attributes :id, :user_id, :skill_id, :strength, :capacity, :learned
end
class RecipeSerializer < ActiveModel::Serializer
embed :ids, include: true
has_many :skills
attributes :id, :title
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment