I think it's because of how my Proposal model is set up but I'm not sure how to get around it.
JSON Response
{
"proposal":[
{
"id":1,
"proposee_id":1,
"proposer_id":4
}
],
"user":{
"id":4,
"username":"rawr",
"email":"rawr@ar.com",
"proposal_id":1
}
}
proposal model (Ember)
App.Proposal = DS.Model.extend
proposer: DS.belongsTo "user"
proposee: DS.belongsTo "user"
status: DS.attr "string"
Proposal Model (Rails)
class Proposal < ActiveRecord::Base
belongs_to :proposer, class_name: "User"
belongs_to :proposee, class_name: "User"
end
User model (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"
User model (Rails - truncated)
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
I figured out why.
I had to change proposal_id
in the JSON response to proposal
.
The change was made in Ember-Data 1.0.0Beta and is addressed here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.