Validating parent quantity domain
This commit is contained in:
parent
b31ab9d16a
commit
a96cd717cf
@ -12,4 +12,8 @@ class Quantity < ActiveRecord::Base
|
|||||||
validates :project, associated: true
|
validates :project, associated: true
|
||||||
validates :name, presence: true, uniqueness: {scope: :project_id}
|
validates :name, presence: true, uniqueness: {scope: :project_id}
|
||||||
validates :domain, inclusion: {in: domains.keys}
|
validates :domain, inclusion: {in: domains.keys}
|
||||||
|
validates :parent, associated: true
|
||||||
|
validate if: -> { parent.present? } do
|
||||||
|
errors.add(:parent, :parent_domain_mismatch) unless domain == parent.domain
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,13 @@ en:
|
|||||||
field_action: 'Action'
|
field_action: 'Action'
|
||||||
field_domain: 'Domain'
|
field_domain: 'Domain'
|
||||||
field_parent_quantity: 'Parent'
|
field_parent_quantity: 'Parent'
|
||||||
|
activerecord:
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
quantity:
|
||||||
|
attributes:
|
||||||
|
parent:
|
||||||
|
parent_domain_mismatch: 'parent quantity has to be in the same domain'
|
||||||
body_trackers:
|
body_trackers:
|
||||||
index:
|
index:
|
||||||
heading: 'Summary'
|
heading: 'Summary'
|
||||||
|
Reference in New Issue
Block a user