How to use Rails or Ruby documentation?
I'm coming from C#, and recently I started to write some Ruby on Rails applications.
My biggest problem with it is the documentation because I find it extremly difficult to 开发者_运维技巧use. For example, finding out how to call generator from my controller took me about 2 hours and then 15 minutes after that I found Rails::Generators.invoke
method to figure out what arguments should I pass to this function.
Maybe I use the documentation the wrong way; First I take a wild guess and search in the Netbeans code completion, which is rarely helpful, then I search in Google, then go with the API.
Can some experienced Rails programmer give me some advice?
If you're new to rails I recommend you read a book before you dive into the API documentation.
Here are two recommendations:
- Agile Web Development With Rails - Great introduction and reference on how to use rails.
- Programming Ruby 1.9: The Pragmatic Programmers' Guide - More on Ruby. Great references!
After you've worked your way through those books, you'll have an idea of how Rails is designed and where to look for stuff.
Both books are great reference books. If you want to access the Rails and Ruby API's online, make sure to checkout RailsApi.com
I am describing my own very personal workflow with Ruby/Rails documentation:
- You can use
ri
andrdoc
if you are familiar with the console, but... Personally, I recommend two very good Ruby/Rails documentation sites:
- apidock.com (no good search, but sometimes fine examples)
- railsapi.com (very good AJAX search, plus you can customize what documentation you would like to see - by versions and by Gems)
Every iteration of the Rails guides (http://guides.rubyonrails.org/) has a ton of useful stuff in it. That should be the first stop.
After that I search away in the API - http://api.rubyonrails.org.
Sometimes I even end up just reading the source code trying to find things - https://github.com/rails/rails.
I think the best place in the source code to be reading is in here - https://github.com/rails/rails/tree/master/railties/lib/rails.
I upvoted each of the other answers here.
精彩评论