Ben*_*enU 3 ruby-on-rails heroku ruby-on-rails-3
我是编程和rails的新手,我想创建一个我正在使用的rails应用程序的副本,以便无害地尝试一些东西.是否有一种简单的方法可以实现这一目标?
是的你可以.对于像我这样的新手来说这些命令并不明显,可能会帮助别人......
首先,根据您打算调用新部署的应用程序的计划,找到heroku上当前可用的名称.
从旧的root和创建新的rails应用程序:
$ cp -R old_directory new_directory
$ cd new_directory
$ rm -rf .git
# find and replace all references to old_director found within new_directory
# the command at the terminal 'grep -ri "old_director" .' may help to locate
# all of the references to the old_directory
$ git init
$ git add .
$ git ci -am “First commit after copying from old_app”
# create new_directory repository at github. Follow along their
# directions for new repository with appropriate modifications.
$ git remote add origin git@github.com:[github username]/[new_directory].git
$ git push -u origin master
$ rake db:migrate
$ heroku create [new_app]
$ git push heroku master
Run Code Online (Sandbox Code Playgroud)
要为新应用生成新的密钥:
$ rake secret # generate new secret key for new app
5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8
Run Code Online (Sandbox Code Playgroud)
接下来,使用以下命令将新创建的密钥保存为Heroku上的环境变量:
$ heroku config:set SECRET_KEY_BASE=5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8
Run Code Online (Sandbox Code Playgroud)
有关将密钥等存储为环境变量的更多细节可以在Daniel Fone的博客上找到.
最后:
$ heroku run rake db:migrate
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
630 次 |
| 最近记录: |