how to deploy ember-cli + rails app on heroku

2019-05-29 13:19发布

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条回答
等我变得足够好
2楼-- · 2019-05-29 13:58

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.

查看更多
登录 后发表回答