Added Targets table
Fixed Quantity#after_save for default quantities
This commit is contained in:
parent
1a807d24d7
commit
61498018e7
@ -26,7 +26,8 @@ class Quantity < ActiveRecord::Base
|
||||
# be no other way to validate against newly changed :name
|
||||
after_save do
|
||||
next unless name_changed? || changes.empty?
|
||||
formulas = project.formulas.where('formulas.code LIKE ?', "%#{name}%").includes(:quantity)
|
||||
formulas = Formula.joins(:quantity).where(quantities: {project_id: project})
|
||||
.where('formulas.code LIKE ?', "%#{name}%").includes(:quantity)
|
||||
next unless formulas.exists?
|
||||
|
||||
quantity_names = formulas.reject(&:valid?)
|
||||
|
@ -92,5 +92,14 @@ class CreateSchema < ActiveRecord::Migration
|
||||
t.timestamp :taken_at
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
create_table :targets do |t|
|
||||
t.references :goal
|
||||
t.references :threshold
|
||||
t.string :condition
|
||||
t.string :scope
|
||||
t.date :effective_from
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user