Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # goal: be able to not always run utc_time ... if I'm updating the time for the call (and not the user). I'll use ruby script/runner etc... but I need a way to distinguish it's me running as opposed to the user editing.
- class Call < ActiveRecord::Base
- #ASSOCIATIONS
- belongs_to :user
- belongs_to :phone
- belongs_to :schedule
- #FILTERS
- before_save :set_utc_time
- #THIS didn't seem to work :(
- attr_writer :is_cron
- # i was thinking of doing this now
- def is_cron=
- end
- def is_cron
- end
- #FILTERS
- def set_utc_time
- return true if @is_cron
- Time.zone = self.time_zone
- self.utc_time = Time.zone.parse(self.local_time_string)
- if self.utc_time < (Time.now.utc)
- self.errors.add(:utc_string, "must be scheduled in the future")
- return false
- end
- end
- end
Add Comment
Please, Sign In to add comment