0
내 엠버 프론트 엔드는 다음과 같이 나에게 데이터를 전송한다 : 여기준 레일 API와 타다 남은 제출에
{
"data":{
"attributes":{
"title":"asd",
"description":"asd"
},
"relationships":{
"users":{
"data":[
{
"type":"users",
"id":"1"
}
]
}
},
"type":"cards"
}
}
, 나는 새로운 card
만들 때 card
과 user
사이에 연결하려는.
응용 프로그램/컨트롤러/cards_controller.rb
def create
@card = Card.new(card_params)
if @card.save
@card.users << User.find(params[:data][:relationships][:users][:data]) if params[:data][:relationships][:users][:data]
render json: @card
else
render json: @card, :status => 422
end
end
private
def card_params
params.require(:data).require(:attributes).permit(:title, :description)
end
레일 끝에서 오류가이 같은 것입니다 :
DEPRECATION WARNING: Method to_a is deprecated and will be removed in Rails 5.1, as `ActionController::Parameters` no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited. Instead, consider using one of these documented methods which are not deprecated: http://api.rubyonrails.org/v5.0.0/classes/ActionController/Parameters.html (called from create at /Applications/AMPPS/www/development/ideast/hub/hub-server/app/controllers/cards_controller.rb:16)
Completed 500 Internal Server Error in 24ms (ActiveRecord: 3.4ms)
NoMethodError (undefined method `join' for #<ActionController::Parameters:0x007f9b5549e380>
Did you mean? JSON):
리포 링크 : 당신이 할 수 있어야한다 생각 https://github.com/ghoshnirmalya/hub-server