Skip to content

Instantly share code, notes, and snippets.

@lessless
Created October 20, 2012 10:33
Show Gist options
  • Save lessless/3922934 to your computer and use it in GitHub Desktop.
Save lessless/3922934 to your computer and use it in GitHub Desktop.
validates :place_id, :title, :level, :start_at, :end_at, :presence => true
validate :event_takes_place_in_one_day, :event_is_not_in_past
def event_takes_place_in_one_day
self.start_at.day == self.end_at.day
end
def event_is_not_in_past
admissible_range = DateTime.now.beginning_of_day..DateTime.now.end_of_month
admissible_range.cover?(self.start_at) && admissible_range.cover?(self.end_at)
end
undefined method `to_datetime' for nil:NilClass
Application Trace | Framework Trace | Full Trace
app/models/meeting.rb:22:in `cover?'
app/models/meeting.rb:22:in `event_is_not_in_past'
app/controllers/meetings_controller.rb:18:in `create'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment