2012-07-31 49 views

回答

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 [email protected]:[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 

有关存储秘密t键等,因为可以在Daniel Fone's Blog上找到环境变量。

最后:

$ heroku run rake db:migrate 
+0

运行'$耙分贝:migrate'其次是'$耙分贝:测试:prepare'或'耙分贝:测试:load',然后运行规范可能是前一个好主意推动git并部署到Heroku。 – BenU 2013-03-17 18:46:17

+0

您是否需要对密钥进行任何更改? – Onichan 2015-11-30 07:04:47

+1

是@Onichan。您应该使用'$ rake secret'生成一个新密钥并将其保存为一个heroku环境变量。我将编辑上述说明以包含这些步骤。 – BenU 2015-12-01 23:37:49