Rails on Heroku
I pushed bookmarks-rails project to Heroku yesterday. Thanks to tutorial i don’t have too many troblem during upload to Heroku. Some parts of doc are out of dated and here i write down the steps for reference myself in the future.
- install heroku toolbelt from heroku
- heroku doesn’t support sqllite3, modify sqllite3 to postgres sql
1
|
|
to
1 2 3 4 5 6 |
|
3.use thin
as production webserver
1 2 3 |
|
- run
bundle install --without production
- In Rails 3.x precompile your assets file, you have to add
config.assets.initialize_on_precompile=false
to yourconfig/application.rb
. Rails 4 ignore this. - run
rake assets:precompile RAILS_ENV=production
- set
config.serve_static_assets = true
in yourproduction.rb
because we use rails to serve static assets - run
git commit -am "your commit message"
because only commited source code will be pushed to heroku. - run
heroku create appname
to create your app on heroku. It requires you input your account,password and your ssh public key(id_rsa). - run
git push heroku master
. You will see your app running on http://appname.herokuapp.com. Heroku will modify your production datbase connection in database.yml when push to heroku. You don’t need to put the production setting your database.yml. - run
heroku run rake db:migrate
to create db on heroku
trouble shooting
If you use Twitter Bootstrap, you have to comment out favicon related codes in your application.html.erb. Or you will fail to push to heroku.
1 2 3 4 5 |
|
If you modify the app name on Heroku web site, you should remove your remote branch and re-add.
1 2 3 |
|