4 ms·
Finally, as far as I can tell Rails 4 doesn’t yet work on Heroku, so all the deployment examples currently fail. Rails 4 definitely works on heroku, what pr
by sync 14y ago
Finally, as far as I can tell Rails 4 doesn’t yet work on Heroku,
so all the deployment examples currently fail.
Rails 4 definitely works on heroku, what problems are you seeing?
Edit: You may be missing "ruby '2.0.0'" or "ruby '1.9.3'" in your Gemfile, as seen in: https://gist.github.com/speedmanly/d15a3a5f8d0971bc0c92 https://gist.github.com/speedmanly/d15a3a5f8d0971bc0c92
- mhartl 14y agoEven with an explicit Ruby line in the Gemfile, I get this error: $ heroku logs . . . heroku[slugc]: Slug compilation failed: unrecognized error Here's the Gemfile: source 'https://rubygems.org' ruby '2.0.0' gem 'rails', '4.0.0.beta1' group :development do gem 'sqlite3', '1.3.7' end group :assets do gem 'sass-rails', '4.0.0.beta1' gem 'coffee-rails', '4.0.0.beta1' gem 'uglifier', '1.0.3' end gem 'jquery-rails', '2.2.1' gem 'turbolinks', '1.0.0' gem 'jbuilder', '1.0.1' group :production do gem 'pg', '0.14.1' end The app is the "first_app" from the book, which is basically the result of running "rails new first_app" plus a slightly modified Gemfile. The full repo is here: https://github.com/mhartl/first_app https://github.com/mhartl/first_app. Any help in getting it to work on Heroku would be much appreciated.
- siong1987 14y agoThat's weird. http://www.cupidwithfriends.com http://www.cupidwithfriends.com is running rails 4 and been on heroku for the past week. Our Gemfile: source 'https://rubygems.org' ruby '1.9.3' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0.beta1'
- mhartl 14y agoThanks. I think I know what the problem is. Tracking it down now... Edit: Yes, I figured it out. In Rails 4.0, the default page for a new app is no longer served as a static file from the public/ directory. Instead, something magical happens, and the magic doesn't work on Heroku. That's no worry, though, as it only means the first app doesn't work. The other apps, which set root routes, should work fine. They don't, though. I can't get the main sample app's CSS or images to load properly. Hmm... Bleeding edge indeed. Update: You need to edit the default production.rb file to configure Rails to serve static assets: config.serve_static_assets = true Thanks to ninthfrank07 for his link at https://news.ycombinator.com/item?id=5411964 https://news.ycombinator.com/item?id=5411964 that included the solution.
- steveklabnik 14y ago> Instead, something magical happens, and the magic doesn't work on Heroku. To be clear, this is because the 'Welcome page' shows info about the server, so you NEVER want that accidentally leaked to the world at large by accident, so the route gets disabled in production mode.
- mhartl 14y agoYou're right, of course, but it's not just that. In previous versions of Rails, the default page (a static file served out of the public/ directory) worked just fine on Heroku. It was only the magical “About your application’s environment” link that didn't work. In Rails 4.0, the static file is gone, and as far as I can tell the entire default page is magic, so on Heroku it breaks in its entirety, too. It's not a big deal of course, as in any real app you'll quickly define a root route and be done with it. (I do consider it a feature, too, as I really like not having to remove the static file by hand.)
- ninthfrank07 14y agoTry following these instructions: https://gist.github.com/peter/3025502 https://gist.github.com/peter/3025502.
- mhartl 14y agoThanks! That link had the missing piece, which is to configure Rails to serve static assets. See https://news.ycombinator.com/item?id=5411968 https://news.ycombinator.com/item?id=5411968.
- sync 14y agoInteresting. Without making any modifications to your app I have it working on heroku: http://safe-harbor-9177.herokuapp.com http://safe-harbor-9177.herokuapp.com Here's the full output: https://gist.github.com/speedmanly/1099b37338745ccb5a26 https://gist.github.com/speedmanly/1099b37338745ccb5a26 Adding a Procfile is generally recommended (although heroku will add a default one) web: bundle exec rails server thin -p $PORT -e $RACK_ENV Setting your rails env is a good idea too: heroku config:add RAILS_ENV=production Note I didn't perform those steps to get the app running, they are just recommended. Edit: Actually I do see this line in my heroku logs: 2013-03-21T00:50:21+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 32752 -e $RAILS_ENV` 2013-03-21T00:50:22+00:00 app[web.1]: bash: bin/rails: No such file or directory Adding a Procfile should fix that. Listing 'thin' (or another rails server, e.g. unicorn,puma) in your Gemfile is a good practice as well.
- mhartl 14y agoThanks. Yes, I just realized that it's "working", even though it shows an error. See https://news.ycombinator.com/item?id=5411968 https://news.ycombinator.com/item?id=5411968. This is new behavior in Rails 4.0, which is why it threw me. The default page works on Heroku going back to Rails 2.3, but they switched things up in the latest version of Rails.
- bdclimber14 14y agoAre you running a Cedar or Bamboo app? Ruby 2.0.0 only works on Cedar.
- janus 14y agoAre you running on the cedar stack? heroku stack You need the cedar stack for the ruby directive to work on the Gemfile
- mhartl 14y agoAll right, based on everyone's feedback I was able to get things working on Heroku and have updated the news post and book accordingly. Thanks! HN rocks.