我认为这是因为我的提案模型是如何设置的,但我不确定如何绕过它。
JSON 响应
{
"proposal":[
{
"id":1,
"proposee_id":1,
"proposer_id":4
}
],
"user":{
"id":4,
"username":"rawr",
"email":"rawr@ar.com",
"proposal_id":1
}
}
提案模型(Ember)
App.Proposal = DS.Model.extend
proposer: DS.belongsTo "user"
proposee: DS.belongsTo "user"
status: DS.attr "string"
提案模型(Rails)
class Proposal < ActiveRecord::Base
belongs_to :proposer, class_name: "User"
belongs_to :proposee, class_name: "User"
end
用户模型(Ember)
App.User = DS.Model.extend
username: DS.attr 'string'
email: DS.attr 'string'
password: DS.attr 'string'
password_confirmation: DS.attr 'string'
proposal: DS.belongsTo "proposal"
用户模型(Rails - 截断)
class User < ActiveRecord::Base
before_save :encrypt_password
attr_accessor :password
has_one :proposal_to, class_name: "Proposal", foreign_key: "proposer_id"
has_one :proposal_from, class_name: "Proposal", foreign_key: "proposee_id"
end