How to copy rails app using git and deployed to heroku

青春壹個敷衍的年華 提交于 2020-01-01 03:36:06

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/11732016/how-to-copy-rails-app-using-git-and-deployed-to-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!