Skip to content

Instantly share code, notes, and snippets.

@scan
Created October 6, 2012 20:54
Show Gist options
  • Save scan/3846085 to your computer and use it in GitHub Desktop.
Save scan/3846085 to your computer and use it in GitHub Desktop.
Get All By Week
class Model < ActiveRecord::Base
attr_accessible :date
def self.find_by_week(week, year)
dates = Date.commercial(year,week)..Date.commercial(year,week+1)
Model.where :date => dates.take(7)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment