Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


single_day? and multi_day? methods #3

merged 1 commit into from

2 participants


I added methods for detecting if an event is on a single day or covers multiple days. Useful in case you want to show "When: 7pm-9m on 6/23" versus "June 23 through June 28" in your views.

Note that the spec file for events appears to depend on files outside the gem itself, so I could not run the tests before starting. If desired, I'd be happy to do my best to add the specs anyway for your use in local testing.


Hell yeah!

@joemsak joemsak merged commit 3efcb07 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 20, 2011
  1. @mdoel
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +8 −0 app/models/event.rb
  2. +1 −1  spec/models/event_spec.rb
8 app/models/event.rb
@@ -54,6 +54,14 @@ def next
def prev
Event.where(['start_at < ?', start_at]).reverse.first
+ def single_day?
+ end_at.blank? || start_at.blank? || (end_at - start_at) < 24*60*60
+ end
+ def multi_day?
+ !single_day?
+ end
def self.archive
with_exclusive_scope { order('start_at DESC').where 'end_at < ?', }
2  spec/models/event_spec.rb
@@ -74,4 +74,4 @@ def reset_event(options = {})
Something went wrong with that request. Please try again.