3

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

4

1 回答 1

9

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

首先,根据您计划调用新部署的应用程序的名称,找到当前在 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 的博客

最后:

$ heroku run rake db:migrate
于 2012-07-31T01:44:09.330 回答