如何在heroku上部署ember-cli + rails应用程序 [英] how to deploy ember-cli + rails app on heroku

查看:152
本文介绍了如何在heroku上部署ember-cli + rails应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过将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

但似乎不起作用 如英雄的应用程序所示 ,而不是显示内容,它在网页上显示raw json,这表示当您通过url输入应用程序时,emberjs路由模型钩子没有被调用。它显示的JSON是这样的:

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

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

解决方案

您将路由请求路由到 speaker#index ,这是为什么在访问 / 时会收到json响应。



您希望您的rails应用程序提供 index.html 所有请求o比 / api ,像

  get'* path'到:'index#show'

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



我还建议在搞定Heroku之前在本地工作。


I am trying to deploy an Ember-cli app by copying the files generated by ember build into the rails public folder following the approach shown in:

   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

But it doesn't seem to work as shown in the app on heroku, rather than display the content, it displays raw json on the web page which suggests the emberjs route model hook is not being called when you enter the app via url. The JSON it displays is something like this:

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

However, if I leave the index.html file generated by ember-build in the rails app/public folder instead of copying the content of the index.html to rails layout/application.html.erb, the content of the ember-cli app's application.hbs will display correctly but if I directly load any route in the browser, it will again return a raw json rather than display the content.

解决方案

You're routing root requests to speaker#index, which is why you're getting the json response when visiting /.

You want your rails app to serve up index.html on all requests other than /api, something like

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

That action should just serve up your Ember CLI project's static index.html file.

I'd also suggest getting this working locally before messing with Heroku.

这篇关于如何在heroku上部署ember-cli + rails应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆