1.修改数据库
heroku使用的是PostgreSql而不是sqlite3,因此需要修改Gemfile以后才可以到heroku上运行。修改Gemfile中的:
gem 'sqlite3'
将它改为:
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
这样在开发环境中使用Sqlite3,在部署上线后使用PostgreSql.
2.加载库
bundle install --without production
3.登录heroku
heroku login
会提示输入email和password,登录成功后新建app:
heroku create --stack cedar
4.push代码
把代码加入到git版本库:
git init
git add .
git commit -m "make it better"
push到heroku:
git push heroku master
可以看到以下输出:
remote: ###### WARNING:
remote: No Procfile detected, using the default web server (webrick)
remote: https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> console, rake, web, worker
remote:
remote: -----> Compressing... done, 28.5MB
remote: -----> Launching... done, v7
remote: https://tuishu.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
To https://git.heroku.com/tuishu.git
2f25861..959154c master -> master
当看到Verifying deploy…. done.的时候说明push完毕。
5.迁移数据库
heroku run rake db:migrate
6.访问app
heroku open
7.2这个命令
远程连接:
heroku git:remote -a tuishu
远程clone
heroku git:clone -a tuishu