app/models/concerns/publishable.rb in cambium-1.2.3 vs app/models/concerns/publishable.rb in cambium-1.3.0
- old
+ new
@@ -15,14 +15,10 @@
Time.now, Time.now, Time.now, nil) }
scope :unpublished, -> { where("active_at > ? OR inactive_at < ? OR
(active_at IS ? AND inactive_at IS ?)",
Time.now, Time.now, nil, nil) }
- # --------------------------------- Callbacks
-
- before_save :convert_dates
-
end
# --------------------------------- Instance Methods
def published?
@@ -50,26 +46,9 @@
end
def formatted_inactive_time
return '' if inactive_at.nil?
inactive_at.strftime("%l:%M %p")
- end
-
- def convert_dates
- self.active_time = Time.now.strftime("%l:%M %p") if self.active_time.blank?
- self.inactive_time = '12:00 AM' if self.inactive_time.blank?
- if self.active_date.blank?
- self.active_at = nil
- else
- self.active_at = DateTime.strptime("#{self.active_date}
- #{self.active_time}", "%d %B, %Y %l:%M %p")
- end
- if self.inactive_date.blank?
- self.inactive_at = nil
- else
- self.inactive_at = DateTime.strptime("#{self.inactive_date}
- #{self.inactive_time}", "%d %B, %Y %l:%M %p")
- end
end
def publish!
update_column :active_at, Time.now
end