我是编程和Rails的新手,我想创建一个我正在使用的Rails应用程序的副本,以无害地尝试一些事情。有没有简单的方法可以做到这一点?

最佳答案

是的你可以。这些命令对于像我这样的新手来说并不明显,可能会对其他人有所帮助...

首先,根据您计划调用新部署的应用程序的方式,找到heroku当前可用的名称。

从旧的根源到要创建的新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


为您的新应用生成新的密钥:

$ rake secret  # generate new secret key for new app
5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8


接下来,使用以下命令将新创建的密钥保存为Heroku上的环境变量:

$ heroku config:set SECRET_KEY_BASE=5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8


可以在Daniel Fone's Blog上找到有关存储私钥等作为环境变量的更多详细信息。

最后:

$ heroku run rake db:migrate

10-07 14:05
查看更多