The Ruby On Rails cheat sheet is designed to be printed on an A4 sheet of paper and live by a developers desk, to make life a bit easier. A description of what is on the cheat sheet follows, or if you are impatient, you can go straight to the full size Ruby On Rails cheat sheet.
I am no expert in Ruby, On Rails or off, so to ensure this cheat sheet was as useful as possible, I pestered the very helpful Amy Hoy of (24)Slash7 and David Heinemeier Hansson of Loud Thinking into giving me a hand. Thanks, both of you - I appreciate it. In the same vein, though the cheat sheet has been checked there is a chance there is the occasional typo - if anybody spots a mistake (or something that could be worded better) please let me know.
Default Directory Structure
Ruby on Rails by default uses a rather large selection of folders and files, organised into a directory structure. This is a great feature, but does occasionally lead to people getting slightly lost and forgetting where to find something, especially if what they are looking for is something they use infrequently. This section shows visually the default directory structure of a Ruby on Rails site.
Pre-Defined Variables
Ruby on Rails, like most languages, includes a large number of predefined variables. These shorthand variable names are often tricky to dig out from the back of the mind when actually needed, so here is a convenient list of the most useful of them.
Reserved Words
In much the same way as Pre-defined variables, Ruby on Rails makes use of reserved words and these are also often not easy to remember. Using them out of context can cause all sorts of problems, so this list is provided to ensure that doesn't happen. Ignore it at your peril!
Regular Expression Syntax
It seems that no matter the language, most developers always spend some time stumbling through regular expressions before they are comfortable with them. Ruby on Rails is no different, and the regular expression syntax is the same familiar syntax as used in PHP and Perl. This section outlines the building blocks of patterns in regular expressions for Ruby on Rails.
Methods
Ruby on Rails is very much an object oriented language. Every object has methods. These sections list the useful methods for working with String, Array, Time and Regex objects. It also lists validation methods and methods from the enumerables mixin - which are some of the most looked-up.
Download
So now that you know what it does, please feel free to print out the Ruby on Rails cheat sheet:
And finally, if you like the cheat sheets, and want to say thanks, please consider buying me something from my Amazon Wishlist. Thankyou very much to those who have already hunted it down and sent me something nice - I'm very grateful!
Please note: If you wish to link to the Ruby on Rails cheat sheet from elsewhere, please link to this page so others find the description, rather than linking directly to the sheet.

82 Comments
Bookmarked!As all the other cheatsheets! ;)
#1, Nando Vieira, Brazil, 11 January 2006. Reply to this.
we are only waiting for a LaTex cheat sheet at that's all folk!
#2, Dapuzz, Italy, 11 January 2006. Reply to this.
I love you cheet sheets, and when I win the lottery I will buy you that cammera on your wishlist
#3, Matt, United Kingdom, 11 January 2006. Reply to this.
Nice! Man, you're the cheat sheet maestro.
#4, brian w., United States, 11 January 2006. Reply to this.
I have three of your other cheat sheets on my wall behind my monitor. This is the best one yet - you rock!
#5, Ryan Heneise, United States, 13 January 2006. Reply to this.
Nice work. The ideal is to bind it to RoR release process in order to automatically generate it.
#6, Ale Bairos, Brazil, 14 January 2006. Reply to this.
I was inspired by Amy Hoy as well and created a cheatsheet (cheat mini-book? 14pages) and it's getting a lot of link-love from del.icio.us, etc.
http://www.blainekendall.com/index.php/rubyonrailscheatsheet/
#7, Blaine, Canada, 18 January 2006. Reply to this.
How about a HTML Cheatsheet? There's some meta tags and things like that I always forget, or some simpler markup I just all too seldom use.
Oh and I might have found a "bug" on your site. Whenever I press tab (I use my keyboard a lot, who needs a mouse, right) the site scrolls to the top, but the selection is set in the correct order. I can only imagine it being some faulty JS.
I use Opera 8.51 and did not test this error in inferior browsers (=all others).
#8, JesusHatesYou, Germany, 22 January 2006. Reply to this.
In your Regular Expression Syntax section, you refer to "[abc]" as a "range". This is a character set and can /contain/ a range with the a-z syntax. Perhaps you'd like to change to something like: "[a-cg]" => A character from the set a, b, c, or g
Much of your "Rails" items are just "Ruby" items. Perhaps having a <gasp/> two-page cheat-sheet where one side is Ruby and the other is Rails? You could include sections on ActiveRecord, ActionPack, ActiveSupport, etc. I was thinking that sections on redirect_to, request.get?, text_field, and the like would be a tremendous addition.
-Rob
#9, Rob Biedenharn, United States, 23 January 2006. Reply to this.
I'll second Rob's suggestion above: since Ruby and Rails are really two very distinct entities, it'd be a great help to have a cheatsheet for each one. The current one is really more of a Ruby cheatsheet -- one that I think most people will find helpful -- but I'd love one that had more Rails-specific stuff.
#10, Michael Granger, United States, 30 January 2006. Reply to this.
I'll third Rob's comments - a focused Rails sheet would be great. Maybe even a simple one going over all the AJAX helper functions in some detail...this would probably be quite popular.
#11, William, Switzerland, 4 February 2006. Reply to this.
Perfect cheat sheets, very helpfull. Keep going on with next ones.
#12, Tom, Poland, 5 February 2006. Reply to this.
Just wondering when the pdf is coming out?
#13, Alex MacCaw, United Kingdom, 9 February 2006. Reply to this.
I'll second the Ruby/Rails seperation thing.
Is there some way you can post the raw photoshop files (or whatever you used to create this)? I'd be willing to work on improving the cheatsheet and dividing it up, but modifying the raw PNG is a mess. If these things were easily modifyable we could keep them up to date to, with the new Rails 1.1 stuff.
Another useful thing for the sheet -- naming conventions, something like this would be great:
SomeClass
SomeModule
SOME_CONSTANT
$SOME_GLOBAL
some_variable
some_method
@some_instance_variable
SomeClass.some_method
#14, Jon, United States, 16 February 2006. Reply to this.
Saw this bit on a http://discuss.joelonsoftware.com/default.asp?joel.3.309321.45
This would be also be a good addition to the cheatsheet:
Rails needs to put a set of simple rules in a place where most newbs will see it. Things like:
-name your tables in the plural
-foreign keys should always be named like so: tableNameInSingularForm_id
So: user_id (foreign key) -> users (table)
-models are named singular
-controllers are plural, at least in some cases
-many-to-many jump tables should be named: alphabeticallyFirstTablePlural_alphabeticallySecondTablePlural
So: axes_users
-columns in many-to-many jump tables should be named like other foreign keys
So: axe_id and user_id
-columns named created_on and updated_on will automatically be populated correctly
#15, Kevin, United States, 16 February 2006. Reply to this.
Here is pdf version of this cheatsheed, I hope some one find it useful.
http://www.lacoctelera.com/myfiles/sitiolejano/ruby_on_rails_cheat_sheet.pdf
#16, Carlos Ardila, Colombia, 8 March 2006. Reply to this.
not sure where to put this, but a useful cheat sheet may be for the "tiny but strong" templating class. its a great class, and having a reference sheet would make it even better, you can find the class at http://tinybutstrong.com/
just a suggestion.
#17, ryan, United States, 28 March 2006. Reply to this.
Great stuff! I've printed this (and a few others) out and I'm sure they will come in handy down the road. Looking forward to more in the future - linux commands, vi, regular expressions? Thanks again!
#18, Doug Johnston, United States, 13 April 2006. Reply to this.
Yes a Ruby and then a Rails cheatsheet would be excellent in terms of helping keep things straight.
#19, ylon, United States, 29 April 2006. Reply to this.
Cool! Thank you for your time and effort and making this cheatsheet available. It certainly does simplify things and make it a bit easier to get my head around RoR.
#20, Donna, Japan, 8 May 2006. Reply to this.
Nice job :)
Still waiting for the real PDF version. Could you spend another 10 minutes in order to post it?!
#21, Anonymous, Romania, 9 May 2006. Reply to this.
Another vote for separate Ruby/Rails cheatsheets. Anyone who's serious about Rails needs to be serious about Ruby as well.
There's so much Rails specific functionality that I'd love to see at a glance. I would even scrap the directory structure just to fit more stuff in. All the ActiveRecord stuff, all the helpers, etc.
#22, Gabe da Silveira, United States, 18 May 2006. Reply to this.
Thanks! I just printed it out on an 8.5x11" glossy photo paper and it looks GREAT!
#23, Chris Busse, United States, 8 June 2006. Reply to this.
So, I've ordered you another item off your wishlist -- would this be enough to inspire you to make us the PDF now? Please, pretty please, with sugar and all that? :D
#24, Dewet Diener, Unknown, 24 June 2006. Reply to this.
Hi, very pretty :) I'd just like to re-iterate the separation between ruby and rails here. I've come via google to look for a rails cheat sheet, and most of this one is ruby stuff (which I am familiar with). Something listing the active record relationships, or the names of the views that can be overriden from the struts,etc. would be most useful.
#25, Jon, United Kingdom, 25 June 2006. Reply to this.
I've added the Ruby on Rails PDF. Xara Xtreme (the new version of my graphics software of choice) now has nice PDF generation built-in. With any luck, that will mean that this PDF is of better quality than the previous ones.
Please let me know if there are problems with the PDF. I'll be regenerating the whole lot over the next couple of weeks and adding PDFs where they are missing.
#26, Dave Child, United Kingdom, 29 June 2006. Reply to this.
Hi,
I found the cheat sheet useful to get started.
Thanks
#27, asia pacific, India, 29 June 2006. Reply to this.
Me ,too.The hardest thing is always to get started.I found the cheat sheet very valuable
#28, Darrell, Canada, 2 July 2006. Reply to this.
Your cheatsheet has been my desktop background for quite some time now, and I actually use it. Great work!
Albert Kok
The Netherlands
#29, Albert Kok, Netherlands, 7 July 2006. Reply to this.
Very useful cheatsheet, thanks alot !
#30, Benjamin, France, 6 September 2006. Reply to this.
I really appriciate your work.
Thanks
#31, Akhil Bansal, India, 5 October 2006. Reply to this.
It is hot =) do not stop! =)
#32, Andriy.Tyurnikov, Ukraine, 27 October 2006. Reply to this.
Man, I just wanted to tell you how much I use your cheatsheets. I've got them printed in A5 (Classic planner size) and put behind a special tab in my planner. I have the RoR, PHP, MySQL, HTML Chars, CSS, JS, ASP and mod_rewrite sheets and just downloaded the reg expressions and microformats. These things are great for when I don't have my library of reference books (like at home on the weekend) and have saved me from 20+ minutes of searching online docs countless times.
I know you probably have tons of suggestions for new cheat sheets, but I thought I'd throw a few out there as well.
* Apache
* Perl
* Bash scripting
* Common .htaccess snippets
#33, Brandon Eley, United States, 3 December 2006. Reply to this.
Hi Brandon,
Glad you like the cheat sheets, and find them useful. Thanks for the suggestions - I've got a few new ones on the way, and will add those to the list to do :)
#34, Dave Child, United Kingdom, 4 December 2006. Reply to this.
Has anyone gotten this cheat sheet to render the fonts on Linux?
#35, Font broken on Adobe Reader for Linux, United States, 19 December 2006. Reply to this.
This printed fine using xpdf on Linux.
#36, Stuart Coyle, Australia, 25 December 2006. Reply to this.
Thnx dude
#37, Nishanth, India, 29 December 2006. Reply to this.
It's good!
#38, Anonymous, United Kingdom, 15 January 2007. Reply to this.
And here's a new Rails website you may be interested in:
www.ChangingThePresent.org
#39, Robert Tolmach, United States, 17 January 2007. Reply to this.
Ruby iss best.
better than java.
only Rubyyyyyyyyyy.
#40, omid, Islamic Republic Of Iran, 6 February 2007. Reply to this.
Very nice cheats!
What about updating Rail's Cheat Sheet? Ruby on Rails 1.2.1 is out there :)
#41, Júlio Santos Monteiro, Brazil, 6 February 2007. Reply to this.
Great site, and awesome Cheat Sheets.
I;m with Julio, how about updating it for Rails 1.2.1?
#42, Michael Noga, Unknown, 14 February 2007. Reply to this.
Thanks for taking the time to share (for free) some concise info on RoR, that dude Dr. Lance is an ass hole.
Also, I love the name of the web-site... Respek!
#43, Edmund, United States, 22 February 2007. Reply to this.
yo, providing the directory-structure in your cheat-sheet is so helpful, need it daily
#44, Allan, Germany, 3 March 2007. Reply to this.
Superb cheatsheet, though I'd like to stick it on my wall in A3 format, so I wouldn't have to stand up, step there and stare at it but look at it from my chair and be able to read it. That is, I'd like you to make an A3 size pdf/png, since if I scale these A4 ones to 200% they lose image quality, and when printed it gets even worse. Thanks in advance.
Regards, cruox.
#45, cruocitae, Romania, 3 May 2007. Reply to this.
Just a heads up: I didn't have the font you used (Verdana bold) on my computer, so the PDF came up gibberish. I'll just download the png instead. If you have the time, you may want to open the file in Acrobat, click on "Document properties" in the file menu, and make sure all the fonts are listed as "embedded subset."
Thanks for the hard work! Great sheets!
#46, sean, Japan, 18 May 2007. Reply to this.
This is so cool. I am RoR fan, see my RoR blog:
http://www.rubyonrailsexamples.com/
#47, Adi Azar, Unknown, 5 June 2007. Reply to this.
Very nice stuff. My company is actually looking for Ruby developers if anyone is interested. Please email me for details!
#48, nlandis@mdlogix.com, United States, 25 June 2007. Reply to this.
Great! Thank you a lot for putting it together.
#49, Roman Mackovcak, Czech Republic, 2 July 2007. Reply to this.
Awesome, awesome, awesome. Thank you.
#50, Adam Miller, United States, 16 August 2007. Reply to this.
It's missing a lot of stuff
link_to ?
form_for ?
text_field ?
#51, Missing, United States, 6 September 2007. Reply to this.
This is a great cheet sheet. I am was looking for some short tuts on rails and found your link on a blog. Could you create some with short examples. That would be great to use as a back up?
#52, Z Solomons, Unknown, 20 September 2007. Reply to this.
^and $ are the beginning and end of the LINE, not the STRING. Please correct this, as it typically leads to security issues.
#53, murphy, Germany, 10 October 2007. Reply to this.
Perfect for the newbie like me. Thanks for taking the time to put this together.
#54, Shad, United States, 28 October 2007. Reply to this.
Nice work. Thank you!
#55, HECTOR RIOS, Unknown, 1 November 2007. Reply to this.
Brilliant cheat sheet. It's now stuck to my wall along with the CSS sheet.
I've just noticed the reserved word "thread" isn't on there.
#56, Dan Webb, United Kingdom, 7 December 2007. Reply to this.
Not cheating at all - just a big help!
#57, Rails @ DreamHost, Unknown, 20 December 2007. Reply to this.
Can't wait for update to Rails2.0, it's amazing and helpful.
#58, John, Australia, 21 January 2008. Reply to this.
thanks! very useful for me :)
#59, savant, Unknown, 10 February 2008. Reply to this.
Aren't ^ and $ for the start and end of the line, and \A and \Z for beginning and end? That could be a validation flaw!
#60, Fat Lotus, United States, 28 February 2008. Reply to this.
Aren't ^ and $ for the start and end of the line, and \A and \Z for beginning and end? That could be a validation flaw!
#61, Fat Lotus, United States, 28 February 2008. Reply to this.
Awesome! Bookmarked your site for later browsing/discovery
#62, Evan Anderson, United States, 1 June 2008. Reply to this.
I great thanks all of your effort.
Many Cheat Sheet are very useful to Me.
#63, Desert Fox, Myanmar, 16 June 2008. Reply to this.
Thanks Friend, Nice effort.
#64, B.U, India, 26 June 2008. Reply to this.
new version for Rails 2.1? So much has changed.
#65, ugr, Unknown, 23 September 2008. Reply to this.
Bookmarked! This is great! =D
#66, Marcus Sá, Brazil, 19 November 2008. Reply to this.
Nice List.
You should update this :)
tons more methods that are nice like .exists?
#67, James Rissler, Unknown, 5 February 2009. Reply to this.
Very well done! I will recommend it to my classmates!
Thanks,
Satelliteko
#68, satelliteko, United States, 22 February 2009. Reply to this.
This is a ruby cheat sheet.
RAILS IS NOT A LANGUAGE. It's just a collection of scripts WRITTEN in Ruby.
Idiot.
#69, pastafari, Unknown, 21 March 2009. Reply to this.
@pastafari: One entire column of this cheat sheet is dedicated to the default Rails directory structure, which is why it's a RoR cheat sheet and not a Ruby cheat sheet.
#70, Dave Child, United Kingdom, 22 March 2009. Reply to this.
Would be nice to see this updated to Rails 2.3... The directory structure has changed.
#71, Joe M, Unknown, 20 May 2009. Reply to this.
Just wanted to point out that the ^ and $ in the Regex don't match the beginning and the end of a string, but those of a line, as opposed to \A and \Z which match the beginning and the end of a string.
#72, Felix, Germany, 14 June 2009. Reply to this.
This is really useful, thanks for creating it!
#73, Jeff, California, 25 June 2009. Reply to this.
Hi, I see several "sections" for the cheatsheet, but, when I download the PDF, can only see one.
Can you re-upload a complete PDF please?
Thanks man
#74, Joao Carlos, Unknown, 7 August 2009. Reply to this.
Woops! My mistake, the thumbnails are actually highlighted versions for each section, not thumbnails of completely diferent pages.
My bad!
#75, Joao Carlos, Portugal, 7 August 2009. Reply to this.
This is perfect for the beginning or advanced RoR developer. Unless you can memorize the methods and functions of Ruby on Rails, then this cheat sheet is a must. If you are looking to get started with Ruby on Rails, the following article is a great place to start http://topcweb.com/content/ruby-rails-setup
#76, Max, United States, 14 October 2009. Reply to this.
Good Ruby cheat sheets are hard to find on the Net. It took me ages to find this.
#77, Kenny, Australia, 25 October 2009. Reply to this.
This is useful but an update to the latest version will be welcome.
#78, Kyle, Ireland, 25 October 2009. Reply to this.
Great cheat sheets! I donated $10GBP...I thought it was like Pesos...but OUCH! Just kidding! Worth every pound!
I need a Yii Framework Cheat Sheet next. THANKS!
#79, Earl, USA, 28 January 2010. Reply to this.
Oh and a jQuery one would be handy also!
#80, Earl, USA, 28 January 2010. Reply to this.
Great Cheat Sheet for starting out!
#81, Jason Green, UK, 1 February 2010. Reply to this.
Oh and a jQuery one would be handy also!
#82, oyunlar, Rotterdam, 21 February 2010. Reply to this.