Created
April 30, 2009 09:58
-
-
Save wallace/104379 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
# model code | |
73 def dtstart_h=(args) | |
74 begin | |
75 self.dtstart = Time.zone.parse("#{args[:date]} #{args[:hour]}:#{args[:minute]}") | |
76 rescue ArgumentError # rescues invalid date format passed to Ruby's date parser | |
77 self.dtstart = Time.now | |
78 errors.add('dtstart', "Invalid date format for the start time. Please use 'YYYY-MM-DD HH:MM'.") | |
79 end | |
80 end | |
# debugger console | |
(rdb:8) p @event.errors | |
#<ActiveRecord::Errors:0x410ddb8 @base=#<Event id: nil, scheduled_type: "CourseSession", scheduled_id: 9287, summary: "", dtstart: "2009-04-30 10:09:15", dtend: nil, duration: 3600, rrule: {"frequency"=>""}, description: "", location: "", dtstamp: nil, account_id: nil>, @errors={"dtstart"=>["Invalid date format for the start time. Please use 'YYYY-MM-DD HH:MM'."]}> | |
(rdb:8) p @event.valid? | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment