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 = Expense.all.sum(:cost, :conditions => {(})

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