Guest User

Untitled

a guest
May 20th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. # 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.
  2.  
  3. class Call < ActiveRecord::Base
  4.  
  5. #ASSOCIATIONS
  6. belongs_to :user
  7. belongs_to :phone
  8. belongs_to :schedule
  9.  
  10. #FILTERS
  11. before_save :set_utc_time
  12.  
  13. #THIS didn't seem to work :(
  14. attr_writer :is_cron
  15.  
  16.  
  17. # i was thinking of doing this now
  18. def is_cron=
  19.  
  20. end
  21.  
  22. def is_cron
  23.  
  24. end
  25.  
  26. #FILTERS
  27. def set_utc_time
  28. return true if @is_cron
  29.  
  30. Time.zone = self.time_zone
  31. self.utc_time = Time.zone.parse(self.local_time_string)
  32.  
  33. if self.utc_time < (Time.now.utc)
  34. self.errors.add(:utc_string, "must be scheduled in the future")
  35. return false
  36. end
  37. end
  38.  
  39. end
Add Comment
Please, Sign In to add comment