Question

I have an Ember app using the ember-rails gem that can create a record and save it to the database. All but one of the model's properties can render in the template. For some reason the 'image' property isn't being sent when Ember requests it.

new_route.js.coffee

App.NewRoute = Ember.Route.extend

    model: ->
        App.Post.createRecord()

    setupController: (controller, model) ->
        controller.set('content', model)

new_controller.js.coffee

App.NewController = Ember.ObjectController.extend
    templateName: "new"

    content: 
        title: @title
        image: @image
        body: @body

    actions: 

        createPost: ->
            @content.save()

post_route.js.coffee:

App.PostRoute = Ember.Route.extend
    model: (params) ->
        App.Post.find(params.post_id)

post.hbs:

<h1>{{title}}</h1>

{{imgtag image}}

{{markdown body}}

<p>{{author}}</p>

post.js.coffee

App.Post = DS.Model.extend
    title: DS.attr 'string'
    image: DS.attr 'string'
    body: DS.attr 'string'
    author: DS.attr 'string'

The model has the correct property in Rails console, but the request for it in Ember returns the model without the property even present.

Was it helpful?

Solution

Include :image in your serializer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top