1
0

Added is_binding attribute to Goal

Fixed test_index to check for data rows only
This commit is contained in:
cryptogopher
2020-08-18 17:40:46 +02:00
parent 955125b843
commit 59a14043c8
13 changed files with 43 additions and 21 deletions

View File

@@ -7,9 +7,12 @@ class Goal < ActiveRecord::Base
has_many :quantities, -> { order "lft" }, through: :target_exposures
validates :target_exposures, presence: true
validates :is_binding, uniqueness: {scope: :project_id}, if: :is_binding?
validates :name, presence: true, uniqueness: {scope: :project_id}
def is_binding?
self == project.goals.binding
after_initialize do
if new_record?
self.is_binding = false if self.is_binding.nil?
end
end
end