Sunday, May 29, 2011

Rails Project Deployment To Heroku

1) After trying out the tutorials of creating a simple rails project named 'Cookbook', i have decided to deploy the project to Heroku. Heroku makes deploying rails projects to the web a breeze. So i have decided to stick on to Heroku as of now.
The cookbook tutorials i have tried is from the following link
http://docs.aptana.com/docs/index.php/Get_Rolling_with_Ruby_on_Rails_in_RadRails
This tutorials invovles two tables recipes and categories.

2) After doing the basic sanity testing in the development server, go ahead with the following steps for
    heroku deployment

3) Go to the project directory and enter the command
             git add .
     The above command will create a .git directory in your project directory.

4) Ensure that you are on the master branch using the following command
            git status


5) Commit the files using the following command
            git commit -m "Initial Comment"
    Note the fact that the above command records the changes only in your machine and not on any remote repository. 'git push' is the command which will push the changes to a remote repository.

6) Eventhough this step is not mandatory, its a good practice to push your code changes to a remote social code site such as github. Go to github website and create a new repository named 'Cookbook'.


7) Now push the repository to github using the following commands
           >  git remote add origin git@github.com:lps-162/Cookbook.git
           >  git push origin master
    where lps-162 is my github username and Cookbook is the github repository name

8) Now create a heroku app using the following command
               heroku create
    The above command will create an app with a random name such as
    http://electric-cloud-630.heroku.com/

9) Now push the application to heroku using the following command
                git push heroku master


10) Now, we need to migrate the databases also to the heroku environment.
      To create the database migrations in heroku, run the following command
                heroku rake db:migrate


11) If we want to push the data from the development machine, then we can run the following command
                heroku db:pu

No comments:

Post a Comment