ror突进-p5

调整路由

将主页重定向路由放到config/routes.rb下

root 'topics#index'

上传到hreoku

先create一个新的hreoku项目

localhost:suggestotron alan$ heroku create
Creating app... done, ⬢ boiling-beach-12120
https://boiling-beach-12120.herokuapp.com/ | https://git.heroku.com/boiling-beach-12120.git

设置gemfile中的sqlite参数,注释掉原来的行并把sqlite移动到testdo下面

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
  gem 'sqlite3'
end

并添加一个带pg的production组

group :production do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'pg'
end

修改完成后,使用bundle来更新gemfile

localhost:suggestotron alan$ bundle install

再跑一个db-migrate

localhost:suggestotron alan$ heroku run rake db:migrate
 ▸    Error: No app specified
 ▸    Usage: heroku run --app APP
 ▸    We don't know which app to run this on.
 ▸    Run this command from inside an app folder or specify which app to use with --app APP
 ▸
 ▸    https://devcenter.heroku.com/articles/using-the-cli#app-commands

然后git更新这些修改,push到heroku的git上

localhost:suggestotron alan$ git add .
localhost:suggestotron alan$ git commit -m 'move sqlite & add pg'
localhost:suggestotron alan$ git push heroku master

完成后能成功打开

https://boiling-beach-12120.herokuapp.com/