如何使用git复制rails应用程序并将其部署到heroku [英] How to copy rails app using git and deployed to heroku

查看:108
本文介绍了如何使用git复制rails应用程序并将其部署到heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

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

首先,根据您打算调用新部署的应用程序的计划,找到名称,目前在heroku上可用。



从旧的根目录创建新的rails应用程序:

  $ cp -R old_directory new_directory 
$ cd new_directory
$ rm -rf .git
#查找并替换new_directory中找到的old_director的所有引用
#在终端'grep -riold_director。'中的命令可以帮助找到
#对old_directory
$ git init
$ git add的所有引用。
$ git ci -am从old_app复制后首次提交
#在github上创建new_directory存储库。通过适当修改,沿着他们的
#指示新的存储库。
$ 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

生成一个新的密钥您的新应用程序:

$ $ p $ code $ rake secret#为新应用程序生成新密钥
5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8

code>

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

  $ heroku上配置:设置SECRET_KEY_BASE = 5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8 

有关将密钥等存储为环境变量的更多详细信息,请参见 Daniel Fone的博客



最后:

  $ heroku运行rake db:migrate 


I'm new to programing and rails and I'd like to create a copy of a rails app I'm working with to harmlessly try out some things. Is there an easy way to make that happen?

解决方案

Yes you can. These commands weren't obvious to a newbie like me and may help someone else...

First, depending on what you plan on calling your new deployed app, find a name that is currently available on heroku.

From root of old and to be created new rails app:

$ 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

To generate a new secret key for your new app:

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

Next, save the newly created secret key as an environmental variable on Heroku with the following command:

$ heroku config:set SECRET_KEY_BASE=5ed8c7d9a3bda9cec3887b61f22aa95bf430a3a550407642b96751c7ef0ce8946a161506d6739da0dcaaea8c8f4f8b3335b1fb549e3cc54f0a4cec554ede05f8

More details about storing secret keys, etc., as environmental variables can be found on Daniel Fone's Blog.

Finally:

$ heroku run rake db:migrate

这篇关于如何使用git复制rails应用程序并将其部署到heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆