agenda-libre-ruby/app/models/event.rb

14 lines
394 B
Ruby
Raw Normal View History

2013-12-28 23:45:13 +01:00
class Event < ActiveRecord::Base
belongs_to :region, foreign_key: 'region'
scope :year, -> year {
where "end_time >= ? and start_time < ?",
"#{year}-1-1", "#{year.to_is+1}-1-1"
}
scope :month, -> year, month {
where "end_time >= ? and start_time < ?",
"#{year}-#{month.to_i-1}-1", "#{year}-#{month.to_i+2}-1"
}
scope :region, -> region { where region: region }
end