1

Rails API を使用して JSON を返し、それをEntityEmber アプリのモデルで使用しています。これは正常に機能しlocalhostますが、アプリを Heroku にデプロイすると機能しません。コンソールに次のエラーが表示されます。

"Error while loading route: entities" "e.addArrayObserver is not a function" 
"P<._setupArrangedContent@http://myappadress.herokuapp.com/assets/application-ac292d8e3f9c271670b08f58e5920cf3.js:14

これは、API から JSON データにアクセスするために使用するメソッドEntityを持つ Emberのモデルです。get_by_addr

    App.Entity = Ember.Object.extend({})


    App.Entity.reopenClass get_by_addr: (addr) ->
      $.getJSON("api/v1/entities?addr=" + addr ).then (response) ->
         entities = []
         a = App.Entity.create response
         a

これは私の「エンティティ」ルートです

    App.EntitiesRoute = Ember.Route.extend
       model: (params)->
       App.Entity.get_by_addr(params.addr)

これはRailsのapplcation.jsファイルです

    //= require jquery
    //= require jquery_ujs
    //= require foundation
    //= require ember_application
    //= require_tree .

これは私の production.rb ファイルです

    Rails.application.configure do

        # Disable Rails's static asset server (Apache or nginx will already do this).
        config.serve_static_assets = false

        config.assets.js_compressor = :uglifier
        # config.assets.css_compressor = :sass

        # Do not fallback to assets pipeline if a precompiled asset is missed.
        config.assets.compile = false

        # Generate digests for assets URLs.
        config.assets.digest = true

        # Version of your assets, change this if you want to expire all your assets.
        config.assets.version = '1.0'

        # Specifies the header that your server uses for sending files.
        # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
        # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

        # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
        # config.assets.precompile += %w( search.js )
        config.ember.variant = :production
4

1 に答える 1

0

これは CoffeeScript の正しいフォーマットですか? あなたの後にthenもう1レベルインデントする必要があると思います。

App.Entity.reopenClass get_by_addr: (addr) ->
  $.getJSON("api/v1/entities?addr=" + addr ).then (response) ->
  entities = []
  a = App.Entity.create response

次に、 がどのようaddrに渡されるかという問題があります。それlink-toがメモリからの場合、 params は自動的に beyond に渡されませんid

于 2014-06-04T10:22:31.520 に答える