Cheat Gem - Cheat Sheets for Ruby and Rails
Alright, kickin this new blog off with a nice little gem from Err the Blog called Cheat.
Cheat, as you might have guessed from the title of this post, gives you quick access to quick and dirty cheat sheets for Ruby and Rails.
It goes a little like this:
Install the gem
$ gem install cheat
Run the cheat command to see a cheat sheet
$ cheat belongs_to
belongs_to:
Options for belongs_to
:class_name - specify the class name of the association. Use it only if that
name can’t be inferred from the association name. So has_one :author will by
default be linked to the Author class, but if the real class name is Person,
you’ll have to specify it with this option.
:conditions - specify the conditions that the associated object must meet in
order to be included as a "WHERE" sql fragment, such as "authorized = 1".
...
It's easy to add new cheat sheets at http://cheat.errtheblog.com/, so in that spirit I added cheat sheets for Ruby and Rails assertions (they may have changed since I added them).
Just try
$ cheat assertions
or
$ cheat assert_select
You can also add Cheat support in TextMate, thanks to a snippet from Ed Silva:
- Open TextMate's bundle editor
- Create a new command
- Put the following code in the body
word=${TM_SELECTED_TEXT:-$TM_CURRENT_WORD} echo "<html><head><title>Cheat Sheet for $word</title></head><body><pre>"; /usr/local/bin/cheat $word; echo "</pre></body></html>"; - Change the output to Show as HTML
- Click on Activation and set it to a keyboard shortcut (such as ctrl-c)
You can now highlight a word and hit ctrl-c to get the cheat sheet! Crescent fresh!


Write a comment