Move Translation class inside Budget
The reason to move Translation class is explained here [1]
[1] 106649a8a5
This commit is contained in:
committed by
voodoorai2000
parent
3b03e583f9
commit
0011a0b4c7
@@ -229,4 +229,16 @@ class Budget < ApplicationRecord
|
|||||||
slug.nil? || drafting?
|
slug.nil? || drafting?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Translation < Globalize::ActiveRecord::Translation
|
||||||
|
validate :name_uniqueness_by_budget
|
||||||
|
|
||||||
|
def name_uniqueness_by_budget
|
||||||
|
if Budget.joins(:translations)
|
||||||
|
.where(name: name)
|
||||||
|
.where.not("budget_translations.budget_id": budget_id).any?
|
||||||
|
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user