You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two models that we'd like to be created in the same request.
Resource
module API
module V1
class ProjectToolboxTalkResource < JSONAPI::Resource
attributes :date
has_one :toolbox_talk
has_one :superintendent
has_one :project
has_many :attendees
has_many :project_toolbox_talk_users
end
end
end
It's happening because you didn't defined projects as a relationship of project_toolbox_talks. Then you just need to add the following line to ProjectToolboxTalkResource :
has_many:projects
It's worth to mention that you may get in trouble trying to add project_toolbox_talk_users since attributes are not allowed for the relationship member:
So if you go for this workaround and start getting some error responses for using the attributes on relationship objects, I recommend you to extract its values and delete the key (attributes) from params[:project_toolbox_talk_users][n][:project_toolbox_talk_users].
I have two models that we'd like to be created in the same request.
Resource
POST Request
When I make the POST request I get the following error even though I have linked project with
has_one :project
What am I not understanding?
The text was updated successfully, but these errors were encountered: