Skip to content

Instantly share code, notes, and snippets.

@hexorx
Created January 6, 2009 22:16
Show Gist options
  • Save hexorx/44045 to your computer and use it in GitHub Desktop.
Save hexorx/44045 to your computer and use it in GitHub Desktop.
def self.previous_cycle user, cycle = nil
cycle ||= Date.today
previous_cycle = find(:first, :select => 'distinct billed', :conditions => ['user_id = ? AND billed < ?', user, cycle], :order => 'billed DESC')
previous_cycle ? previous_cycle.billed : nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment