special offers backoffice is ready now
This commit is contained in:
16
back-office/app/models/special_offer.rb
Normal file
16
back-office/app/models/special_offer.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class SpecialOffer < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
belongs_to :category
|
||||
belongs_to :section
|
||||
belongs_to :sub_category
|
||||
has_many :items
|
||||
|
||||
validates_presence_of :beginning, :ending, :image_url
|
||||
validate :validate_beginning_before_ending
|
||||
|
||||
def validate_beginning_before_ending
|
||||
if beginning && ending
|
||||
errors.add(:ending, "End date must come after beginning date") if ending <= beginning
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user