在heroku上部署Rails和遇到的问题
程序员文章站
2022-07-15 12:52:35
...
1.Heroku 使用 PostgreSQL(发音 post-gres-cue-ell,经常简称 Postgres),所以我们要把 pg
加入生产组,Rails 才能和 PostgreSQL 通信:
group :production do gem 'pg', '0.15.1' end
2.login heroku
$ heroku login
3.heroku create
$ cd your app $ heroku login
4.through git push your app to heroku:
$ git push heroku master
5.change app name
$ heroku rename newname
6.first you need to precompile your app assets:
$ rake assets:precompile
because rails will compiled all assets in one file and save it at the direction '/public/assets/' which named of a MD5 code.
7.second you need to open the file at '/config/environment/production.rb' and then change config.serve_static_assets from false to true.
8.you need to execute step 6 before everytime you push code to heroku.
9.reset postgres database:
$ heroku pg:reset postgres
then input your app's name.
上一篇: Rails事物Transaction
下一篇: Rails常用命令