fix cost_object validation

- would not work for invalid ids
- use "inclusion" message instead of generic "invalid" message
pull/6827/head
Jan Sandbrink 10 years ago
parent 6cd7c3603f
commit 5663c07580
  1. 6
      lib/open_project/costs/patches/work_package_patch.rb

@ -99,9 +99,9 @@ module OpenProject::Costs::Patches::WorkPackagePatch
end
def validate_cost_object
if cost_object && cost_object.changed?
unless (cost_object.blank? || project.cost_object_ids.include?(cost_object.id))
errors.add :cost_object, :invalid
if changed.include? 'cost_object_id'
unless (cost_object_id.blank? || project.cost_object_ids.include?(cost_object_id))
errors.add :cost_object, :inclusion
end
end
end

Loading…
Cancel
Save