views:

72

answers:

2

I'm trying to run this method which should work according to this:

ActiveSupport::TimeZone.new("whatever",3600)

but this initializer doesn't exist.

So I would like to look at the sources for my Rails version (2.3.4) to see if it's private or if I'm missing the point completely (the one-argument constructor works).

And suddenly I realize that I have no idea where to find the docs for my version nor the API. I use api.rubyonrails.org constantly (linked from here), but I'm not even sure what version it refers to (2.3.2, the 'current' version?). How can I get the API docs for my installation? How can I view the SOURCE for my Rails version? Can I view it in my Rails installation (either OSX or Ubuntu)? Online?

If the version were vendored (it's not), how would that affect my question?

+1  A: 

There are several ways to get at your docs, the easiest being with a frozen rails gem. If you don't want to freeze it for some reason you can create a dummy rails app, freeze rails, and gen the docs:

rails dummy_app
rake rails:freeze:gems
rake doc:rails
rake rails:unfreeze

You can also generate docs for plugins you have installed. Try rake -T doc.

Freezing your rails gem has the added benefit that the code is right there for you to browse, but you can always go to wherever your gems get installed on your system. On MacOS this could be either ~/.gems, /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems, or maybe other?

hgimenez
Yeah? And how is that simpler than running `gem rdoc rails`?
Leonid Shevtsov
Definitely, good point.
hgimenez
+1  A: 

Check out http://github.com/makandra/aegis/tree/master for a local gem documentation server. Even simpler is the gem server command. Both give documentation for installed versions of gems.

Also, sometimes gem install skips generating RDoc documentation; use gem rdoc --all to create docs for all installed gems. The docs are saved to /your-ruby-path/lib/ruby/gems/1.8/docs, by the way.

The source for all gems is at /your-ruby-path/lib/ruby/gems/1.8/gems, that includes both Rails and ActiveSupport, which are actually two separate gems.

Leonid Shevtsov
Wow. checking this out now. I thought that all that freezing unfreezing stuff was a bit freaky.
Yar
Man, why didn't I know this? Perfect answer, thank you Leonid.
Yar