Sha256: 92d35bd17593d7dd048438c221e0168a75901bf3c0f21c2af661389f6c706c07

Contents?: true

Size: 483 Bytes

Versions: 5

Compression:

Stored size: 483 Bytes

Contents

module Spree
  # Notification class
  class Notification < ActiveRecord::Base
    validates_presence_of :notification
    validate :end_date_greater_than_start_date

    def end_date_greater_than_start_date
      if start_date.blank?
        errors.add(:start_date, 'is required')
      elsif end_date.blank?
        errors.add(:end_date, 'is required')
      elsif end_date < start_date
        errors.add(:end_date, 'should be greater than start date')
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_custom_notifications-0.5 app/models/spree/notification.rb
spree_custom_notifications-0.4 app/models/spree/notification.rb
spree_custom_notifications-0.3 app/models/spree/notification.rb
spree_custom_notifications-0.2 app/models/spree/notification.rb
spree_custom_notifications-0.1 app/models/spree/notification.rb