Skip to content

Jul 26 / Rupak Ganguly

How to: Edit Rails app online with HerokuGarden

In a previous post, I talked about How to: Deploy application from Git repo to Heroku. Now, let’s be a little more adventurous and see if we can make changes to code using an online code editor at HerokuGarden. That gives us immense freedom to make changes to our application from anywhere you are as long as you have an internet connection and a browser. Let’s see step-by-step how that can be done.

Install HerokuGarden

1. First, let’s install HerokuGarden gem on our local machine

By issuing the following command, we will install the herokugarden gem.

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ gem install herokugarden

---> Installing herokugarden v0.4.2
---> Migrate local checkouts using the git:transition command:

     cd myapp/
     herokugarden git:transition

Successfully installed herokugarden-0.4.2
1 gem installed
Installing ri documentation for herokugarden-0.4.2...
Installing RDoc documentation for herokugarden-0.4.2...

Note that if you had a cloned your Heroku repo to your local machine, you could issue the command as below to move that code to HerokuGarden. So, in our case we get an error as our local machine is not cloned from Heroku repo but cloned from Unfuddle/GitHub repo.

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ herokugarden git:transition

The current directory does not contain a known Heroku app.

I personally like my master copy of the application code to be in my choice of git repo provider and not Heroku. The Heroku repo is only used as a temporary repo for deployment purposes.

2. So, let’s see what herokugarden gem has to offer. The following command lists all the available commands along with their usages.

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ herokugarden
=== Heroku Garden Commands
  list - list your apps
  create [<name>] - create a new app
  info <app> - show app info, like web url and git repo
  update <app> - update the app
    --name <newname>
    --public (true|false)
    --mode (production|development)
  sharing <app> - manage collaborators
    --add <email>
    --remove <email>
    --access (edit|view)
  rake <app> <command> - remotely execute a rake command
  destroy <app> - destroy the app permanently
  keys - manage your user's ssh public keys for git access
    --add [<path to keyfile>]
    --remove <keyname or all>

Example story:
  herokugarden create myapp
  git clone git@herokugarden.com:myapp.git
  cd myapp
  (...make edits...)
  git add .
  git commit -m "changes"
  git push
  herokugarden update myapp --public true --mode production

Create a new application

3. Now, let’s create a new application at HerokuGarden. Well, I know, we already have an application “QParty” with so much code. Don’t worry, we just need to create an application at HerokuGarden so that HerokuGarden creates a repo for us. We will overwrite all the application code that HerokuGarden generates by default, with our latest code from our Unfuddle/GitHub master code repo. I will show you how in a moment.

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ herokugarden create qparty
Created http://qparty.herokugarden.com/ | git@herokugarden.com:qparty.git 

4. Let’s see if our app is created at HerokuGarden.

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ herokugarden list
Enter your Heroku credentials.
Email: rupakg@gmail.com
Password:
Uploading ssh public key C:\Users\Rupak/.ssh/id_rsa.pub
qparty

5. Now, recall that to push to a git repo we need to tell git about a remote. We already have two remotes as below:

a) Unfuddle/GitHub (master code repo)

b) Heroku (deployment repo)

We need to add the repo for HerokuGarden (online code repo) created automatically in step 3. when we created the app on HerokuGarden. We will add a remote to this third repo by issuing the following command:

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ git remote add herokugarden git@herokugarden.com:qparty.git

6. Now, that we have a remote setup we can easily push our latest code to the online code repo at HerokuGarden.  The following commands do exactly that:

Rupak@RG4WIX /c/MyStuff/SvnCode/GitRepo/qparty
$ git push -f herokugarden master
Counting objects: 620, done.
Compressing objects: 100% (431/431), done.
Writing objects: 100% (620/620), 359.36 KiB | 55 KiB/s, done.
Total 620 (delta 188), reused 544 (delta 151)
refs/heads/master: 34dcb40a5a6b24d05a9cf9f709ce0236643a79e3 -> 64d9cfb515701f4faee62d703b9
0d195e998416e
HEAD is now at 64d9cfb... fixed title yet again
master -> master (forced update)it
Running migrations...
App restarting...
######################################################################## 100.0%

Deployed to http://qparty.herokugarden.com

7. Let’s see if our code has been successfully deployed to HerokuGarden. Go to http://qparty.herokugarden.com and we see our code online. Yeah.

herokugarden

That’s it. You have connected to your git rep, deployed code to HerokuGarden online editor. Now, you have the freedom to code anywhere and instantly deploy you changes. Enjoy!

Leave a Comment