Class: PurchaseRequest
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PurchaseRequest
- Defined in:
- app/models/purchase_request.rb
Instance Method Summary collapse
Instance Method Details
#check_price ⇒ Object
44 45 46 |
# File 'app/models/purchase_request.rb', line 44 def check_price errors.add(:price) unless self.price.nil? || self.price > 0 end |
#set_date_of_publication ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/purchase_request.rb', line 48 def set_date_of_publication return if pub_date.blank? begin date = Time.zone.parse("#{pub_date}") rescue ArgumentError begin date = Time.zone.parse("#{pub_date}-01") rescue ArgumentError begin date = Time.zone.parse("#{pub_date}-01-01") rescue ArgumentError nil end end end self.date_of_publication = date end |