The King is dead, long live the King!!! OMG a post! Yes, I have been really busy with so much going on that I actually literally stopped using my laptop at home. It is hard not to be considered a workaholic those days so I have spent most of my time, outside, enjoying the countryside. Rather strange for someone living in the UK but I assure you the weather is actually quite nice in the Midlands. Not Bora Bora yet but pleasant enough to spend the time outside in the green hills. Now, I am back for a good reason. I have decided to learn Ruby on Rails. I started 2 years ago and never really got anywhere with it because I did not really have a project in mind. It is like sitting on a bench at uni, listening to Fourier transforms without having any purpose in doing so. Drooling on your notebook might be the best thing that could happen to you.

Anyway, I am now well underway with Ruby on Rails and start to get grasp of how everything fits together. And I actually like it. It has been many years since I have not touched any object oriented language and starting again with RoR makes a lot of sense in the world of web design. After all an application is a series of models that interact with each other and the display of those is just a means of communication to the user.

As with all new framework, we have got new cheat sheets to help. I have gathered some great ones but needed to create a basic one tailored to my very limited needs.

This is the purpose of this post. I probably will be updating the cheat sheet but for now, here it is. In the scope we have got git, gitHub, Heroku and obviously rails.

  1. // Git
  2.  
  3. // initialize git repository in app folder
  4. $ git init
  5.  
  6. // add all files in project folder, recursively
  7. $ git add .
  8.  
  9. // publish all local changes -m flag for description
  10. $ git commit -a -m "description of commit"
  11.  
  12. // restore previous commit and overwrite existing files
  13. $ git checkout -f
  14.  
  15. // create new branch
  16. $ git checkout -b "branch name"
  17.  
  18. // display all local branches
  19. $ git branch
  20.  
  21. // switch to master branch or replace master by branch id
  22. $ git checkout master
  23.  
  24. // merge branch1 into branch2
  25. $ git checkout branch2
  26. $ git merge branch1
  27.  
  28. // delete branch
  29. $ git branch -d "branch name"
  30.  
  31. // GitHub
  32.  
  33. // add GitHub as origin for main branch
  34. $ git remote add origin git@github.com:<username>/app_name.git
  35.  
  36. // push application to GitHub
  37. $ git push origin master
  38.  
  39. // push application into GitHub
  40. $ git push origin master
  41.  
  42. // push changes into GitHub
  43. $ git push
  44.  
  45. // Heroku
  46.  
  47. // push master branch of application
  48. $ git push heroku master
  49.  
  50. // open heroku
  51. $ heroku open
  52.  
  53. // Rails - Models
  54.  
  55. // install annotate_models plugin
  56. $ script/plugin \http://repo.pragprog.com/svn/Public/plugins/annotate_models
  57.  
  58. // run annotate_models
  59. $ rake annotate_models
  60.  
  61. // execute annotate_models with git commit
  62. # add following call to .git/hooks/pre-commit file
  63. rake annotate_models > /dev/null
  64. # then make hook executable
  65. $ chmod +x .git/hooks/pre-commit
  66.  
  67. // trace SQL statements in console mode
  68. $ tail -f log/development.log
  69. Download this code: Click to download the above coderails_cheat_01