Move Translation class inside Budget::Group
The reason to move Translation class is explained here [1]
[1] 106649a8a5
This commit is contained in:
committed by
voodoorai2000
parent
da1c5fdb01
commit
c2f393276a
@@ -40,5 +40,18 @@ class Budget
|
||||
slug.nil? || budget.drafting?
|
||||
end
|
||||
|
||||
class Translation < Globalize::ActiveRecord::Translation
|
||||
delegate :budget, to: :globalized_model
|
||||
|
||||
validate :name_uniqueness_by_budget
|
||||
|
||||
def name_uniqueness_by_budget
|
||||
if budget.groups.joins(:translations)
|
||||
.where(name: name)
|
||||
.where.not("budget_group_translations.budget_group_id": budget_group_id).any?
|
||||
errors.add(:name, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user