i am making an api. i have 3 models the users the projects and the projectmemberships with associations of:
user.rb
- has_many :projects, dependent: :destroy
- has_many :projectmemberships
- has_many :membered_projectmemberships, :class_name => "projectmemberships", :foreign_key => "project_id"
- has_many :membered_projects, :through => :membered_projectmemberships, :source => :project
project.rb
- belongs_to :user
- has_many :pmembers, :through => :projectmemberships
projectmembership.rb
- belongs_to :user
- belongs_to :project, :class_name => "Project"
- belongs_to :pmember, :class_name => "User"
i could get users membered to a project through the pmembers in the show.jbuilder
json.pmembers @project.pmembers, :id,:name
but now i dont know how to get the projects the users is membered to i try to follow the tutorial of http://ift.tt/1riQTaC
but i get is a uninitialized constant User::projectmemberships
when i try json.membered_projects @user.membered_projects, :id, :name
Aucun commentaire:
Enregistrer un commentaire