Use Range to your advantage in conditionals (ruby/rails)
Handy tip, when trying to find all entries from a model that correspondences to a range, you can use a range in your conditionals.
an example:
date = Time.now
Expense.all.sum(:cost, :conditions => {(date.beginning_of_week..date.end_of_week)})
to find out the total cost of all expenses for the whole of this week.Side note:1) beginning_of_week, end_of_week are ActiveSupport Extensions for time calculations that can be found http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Calculations.html