When looking at my own Rails code and that of the community as a whole, I often see places where certain Rails techniques could have been used, but weren't. As much for my own memory as yours, I thought I'd list down some Rails tricks and tips that can make your application or code more efficient:
Benchmark logic in your controller actions - It's really easy. Use the benchmark class method available on all your models like this:
User.benchmark("adding and deleting 1000 users") do
1000.times do
User.create(:name => 'something')
x = User.find_by_name('something')
x.destroy
end
end
Of course, your code would be a lot better
The regular SQL logs are not shown when within the benchmark sections. Only the benchmark results are shown.