0
我一直在嘗試渲染數據在相同的視圖,似乎不能得到正確的東西。我希望能夠在地點展示廣告網絡上呈現每個地點的評分。Ember和Rails一對多關係
這是我得到的。
我已經嘗試了不同的路線和不同的資源嵌套,以及在鐵軌控制器中渲染不同的東西。我可以找回正確的評級哈希,但不知道如何顯示它。
我假設在我的導軌控制器中出現了問題,或者我需要在把手視圖中執行某些操作。我已經嘗試了很多東西,所以我甚至沒有發佈我的鐵軌東西。如果這個Ember的東西是正確的,那麼使用車把和軌道控制器渲染它的正確方法是什麼。
App.Router.reopen
location: 'history'
rootURL: '/'
App.Router.map ->
@resource 'users', ->
@route 'new',
@route 'edit',
path: '/:user_id/edit'
@route 'show',
path: '/:user_id'
@resource 'locations', ->
@route 'new',
@route 'show',
path: '/:location_id'
@resource 'ratings', ->
@route 'new',
@route 'show',
path: '/:ratings_id'
App.Rating = DS.Model.extend(
rating: DS.attr('string', defaultValue: "-0")
description: DS.attr('string', defaultValue: "No Description Provided")
location: DS.belongsTo("App.Location")
)
App.Location = DS.Model.extend(
name: DS.attr('string', defaultValue: "")
address: DS.attr('string', defaultValue: "")
city: DS.attr('string', defaultValue: "")
state:DS.attr('string', defaultValue: "")
ratings: DS.hasMany('App.Rating')
fullAddress: (->
"http://maps.google.com/?q=#{@get('address')},#{@get('city')},#{@get('state')}}"
).property('address')
)
App.Store = DS.Store.extend(
revision: 11
adapter: DS.RESTAdapter.create(mappings:
ratings: App.Rating
)
)