首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ember-rails在heroku上不起作用

Ember-rails在heroku上不起作用
EN

Stack Overflow用户
提问于 2014-06-04 18:04:01
回答 1查看 139关注 0票数 1

我使用Rails API返回JSON,然后在Ember应用程序的Entity模型中使用它。虽然这在localhost上运行良好,但当我将应用程序部署到Heroku时却无法正常工作;它在控制台上显示以下错误:

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

这是我在Ember中的Entity模型,它有一个get_by_addr方法,我使用它从我的应用程序接口访问JSON数据。

代码语言:javascript
复制
    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

这是我的‘实体’路由

代码语言:javascript
复制
    App.EntitiesRoute = Ember.Route.extend
       model: (params)->
       App.Entity.get_by_addr(params.addr)

这是我在Rails中的applcation.js文件

代码语言:javascript
复制
    //= require jquery
    //= require jquery_ujs
    //= require foundation
    //= require ember_application
    //= require_tree .

这是我的production.rb文件

代码语言:javascript
复制
    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
EN

回答 1

Stack Overflow用户

发布于 2014-06-04 18:22:32

这是CoffeeScript的正确格式吗?我认为在你的then之后,你需要再缩进一个级别。

代码语言:javascript
复制
App.Entity.reopenClass get_by_addr: (addr) ->
  $.getJSON("api/v1/entities?addr=" + addr ).then (response) ->
  entities = []
  a = App.Entity.create response

第二件事,有一个关于addr是如何传入的问题:如果它是一个来自内存的link-to,参数不会自动传递到id之外。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24034510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档