简体   繁体   中英

Can't get model property from Ember/Rails app

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.

在序列化器中包括:image。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM