how to deploy ember-cli + rails app on heroku

雨燕双飞 提交于 2019-12-08 04:50:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/27209549/how-to-deploy-ember-cli-rails-app-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!