December 16, 2006

Posted by John

Tagged search

Older: Default Options for JavaScript Classes

Newer: A Handy Use Of to_s

Finding Help Fast

As I mentioned in my previous post on Textmate shortcuts, keeping your train of thought while programming is really important. Searching through documentation to find a method name or the available parameters kills your train of thought. Recently, I have leveraged the sweetness of Firefox quick searches to help me in this matter. Watch the screencast linked below to see what I’m talking about and then read the rest of the post to learn how.

Watch The Ruby/Firefox Keyword Search Screencast

I continually forget the form helpers. Is it form_for, form_tag, checkbox_tag or check_box_tag? Oh, and don’t get me started on options_from_collection_for_select or whatever those methods are. Anyway…I discovered Ruby Search a while ago but didn’t really use it much at first. I’m a big time minimalist while I’m coding. I open only the apps that I need and I try to keep my tabs to 3 or 4 in my browser. Having an entire tab devoted to some search engine is out of the question. What I like to do is open a new tab, search the docs and close the tab so that I can remain in my wonderfully minimalistic tabdom.

You may or may not know this but Firefox can associate keywords with bookmarks and it even allows passing in parameters which can be used as search terms in a bookmark query string.

Searching Rails API and Caboo.se Edge Cracked Docs

I combined the search results of Ruby search with the keyword bookmark searches to create a quick and easy way of me searching the rails api docs, caboo.se’s edge cracked docs and the pickaxe all in one swoop.

Just create a new bookmark in firefox named ruby search. Make it’s keyword ‘ruby’ and set the location to:

http://labs.parkerfox.co.uk/ruby.search/search_ruby.cgi?search=%s

Ruby Search

Now I can type, ‘ruby form_for’ or ‘ruby link_to’ and instantly have links to the docs. Very handy.

Searching Ruby Core Classes

The only problem with the ruby search is that it doesn’t search the ruby core classes (or at least doesn’t work if it does). Knowing that, I made another bookmark named ‘Ruby Core Docs’, with a keyword of ‘core’ and a location of:

http://www.ruby-doc.org/core/classes/%s.html

Ruby Core Classes Search

Array, String and Hash are a few classes that I lookup multiple times in a day. Using the previous keyword bookmark, I can simply type ‘core String’ in the browser url bar and I’m taken straight to the ruby core docs for String.

Hope you find these shortcuts as useful as I do and that they boost your Rails efficiency. I’m hoping to start using screencasts a bit more as I think they can really be effective in learning new techniques. Maybe I’ll even talk on the next one. :)

4 Comments

  1. I had the same problem has you, but I also needed to look for css or html properties for example, so I have created index search . I have a keyword bookmark is and so I can find docs using

    • is ruby class String
    • is rails ActiveRecord::Base
    • is css background-repeat
    • is js Ajax.Request
      for example.
  2. @Damien – Very cool. Added as a keyword search for me.

  3. Excellent tip, new to Ruby and was finding it hard to get at this sort of help easily.

  4. clever idea john,

    glad ure finding ruby.search useful :)

Sorry, comments are closed for this article to ease the burden of pruning spam.

About

Authored by John Nunemaker (Noo-neh-maker), a web developer and programmer who has fallen deeply in love with Ruby. More about John.

Syndication

Feed IconRailsTips Articles - An assortment of howto's and thoughts on Ruby and Rails.

Feed IconRails Quick Tips - Ruby and Rails related links.