I’m trying to create my first Ember.js app with rails backend. I’m using ember-rails
gem to generate all my folder structure and asset files.
At first, i want to use fixtures instead any kind of api requests and that’s my code
app.js.coffee
window.App = Ember.Application.create(
LOG_TRANSITIONS: true
LOG_ACTIVE_GENERATION: true
LOG_VIEW_LOOKUPS: true
rootElement: 'body'
)
router.js.coffee
App.Router.map ()->
@resource('items')
store.js.coffee
App.Store = DS.Store.extend
adapter: DS.FixtureAdapter
models/item.js.coffee
App.Item = DS.Model.extend(
name: DS.attr('string')
description: DS.attr('string')
)
routes/items.js.coffee
App.ItemsIndexRoute = Ember.Route.extend
model: ->
@get('store').findAll('item')
templates/items.hbs
{{#each item in model}}
{{ item.name }}
{{/each}}
fixtures.js.coffee
App.Item.FIXTURES = [
{
id: 1
name: 'Item 1'
description: 'Lorem ipsum'
}
]
But i’m completely not able to use model
object in my template. It’s empty and ember console also states, that there are 0 Item
elements in the db. What’s more, i’ve recreated that code using jsbin and it works (which blows my mind): http://emberjs.jsbin.com/jigiguwe/2/
My setup:
Ember: 1.5.0
Ember data: 1.0.0-beta.7.f87cba88
Handlebars: 1.3.0
jQuery: 1.11.0
Can anyone advice me how can i debug that issue or what am i possibly doing wrong? Thanks in advance.
Original thread: http://stackoverflow.com/q/22816507/552936