-
-
Save lessless/3922934 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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