【问题标题】:how to deploy ember-cli + rails app on heroku如何在 heroku 上部署 ember-cli + rails 应用程序
【发布时间】:2014-11-30 03:04:17
【问题描述】:

我正在尝试通过将 ember build 生成的文件复制到 rails 公用文件夹中来部署 Ember-cli 应用程序,方法如下所示:

   http://blog.abuiles.com/blog/2014/05/21/deploying-ember-cli-and-rails-to-heroku/

   https://github.com/dockyard/ember-cli-plus-backend/tree/rails-served-html/frontend/app

但它似乎不起作用 as shown in the app on heroku,而不是显示内容,它在网页上显示原始 json,这表明当您输入时未调用 emberjs 路由模型钩子该应用程序通过 url。它显示的 JSON 是这样的:

 [{"id":1,"name":"james","presentation_ids":[1,2]},{"id":2,"name":"charle","presentation_ids":[3]}]}

但是,如果我将 ember-build 生成的 index.html 文件留在 rails app/public 文件夹 中,而不是将 index.html 的内容复制到rails layout/application.html.erb,ember-cli 应用程序的 application.hbs 的内容将正确显示,但如果我直接在浏览器中加载任何路由,它将再次返回原始 json 而不是显示内容。

【问题讨论】:

    标签: ember.js deployment ember-cli


    【解决方案1】:

    You're routing root requests to speaker#index,这就是您在访问/ 时收到 json 响应的原因。

    您希望您的 rails 应用程序为 index.html 提供除 /api 以外的所有请求,例如

    get '*path', to: 'index#show'
    

    该操作应该只提供您的 Ember CLI 项目的静态 index.html 文件。

    我还建议在弄乱 Heroku 之前先在本地工作。

    【讨论】:

    • 谢谢 Sam,我会尝试并回复您。它只部署到heroku,因为看到问题比解释问题更好。
    猜你喜欢
    • 2014-10-11
    • 2014-10-14
    • 2014-08-08
    • 2015-07-06
    • 2016-06-23
    • 2020-05-15
    • 2017-11-07
    • 2015-03-04
    • 2013-01-08
    相关资源
    最近更新 更多