Changed Budget::Investment::Milestones model
Added relation with Status and set condition to validate milestone's description presence if there's no status set.
This commit is contained in:
@@ -11,11 +11,12 @@ class Budget
|
||||
globalize_accessors locales: [:en, :es, :fr, :nl, :val, :pt_br]
|
||||
|
||||
belongs_to :investment
|
||||
belongs_to :status, class_name: 'Budget::Investment::Status'
|
||||
|
||||
validates :title, presence: true
|
||||
validates :description, presence: true
|
||||
validates :investment, presence: true
|
||||
validates :publication_date, presence: true
|
||||
validate :description_or_status_present?
|
||||
|
||||
scope :order_by_publication_date, -> { order(publication_date: :asc) }
|
||||
|
||||
@@ -23,6 +24,11 @@ class Budget
|
||||
80
|
||||
end
|
||||
|
||||
def description_or_status_present?
|
||||
unless description.present? || status_id.present?
|
||||
errors.add(:description)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user