High Rolling With Rails
Once you get started with Rails you should to get to know the Rails code to get the best out of it. The gems that make up Rails, such as ActiveRecord, are script files located under your Ruby installation. In my OS X environment the Rails source files are found in /usr/local/bin/ruby/gems/1.8/. Looking at the Ruby code that makes up Rails will give you greater insight that you can use in your own applications.
Now, the one feature that I use the most when developing in Rails is the logging functionality. In the controller I use the logger instance in most of my actions. Here is a typical use:
def listRecent
@items = Items.find(:all, :order => 'submitted DESC', :limit => 10)
logger << "Found #{@items.size} items..."
end
You can also use the logger’s info, warn, error, and fatal methods as in the following bit of code:
logger.warn "This is a warning"
In the rthml view I use the debug method. Here is how you can use it in your view.
<%= debug params %> <%= debug @items %>