3
Ember Data 호출을 설정하여 이메일 만 포함하는 가입 객체를 만들려고합니다. params가 전달 된 것처럼 보이지만 Rails가 수신 할 수 없기 때문에 Ember Data 설정으로 뭔가 이상합니다. 무엇이 잘못되었는지 확신하지 못합니다.Ember Data가 createRecord를 통해 매개 변수를 올바르게 레일스에 전달할 수 없음
엠버 프론트 엔드 :
var signup = this.get('store').createRecord('signup', {
email: this.get('emailAddress')
});
console.log(this.get('emailAddress')); --> prints fine
console.log(signup); --> data is empty, somewhat alarming/confusing
console.log(signup.get('email')); --> however, this also prints fine
signup.save();
요청 페이로드 :
{"data":{"attributes":{"email":"[email protected]"},"type":"signups"}}
레일 백엔드 :
def create
@signup = Signup.new({ email: params[:email] })
p params
# prints <ActionController::Parameters {"controller"=>"signups", "action"=>"create"} permitted: false>
p @signup --> prints Signup object with nil for email
@signup.save!
render json: @signup
end
응답 페이로드 :
{"data":{"id":"3","type":"signup","attributes":{"email":null}}}