Move Translation class inside Budget::Group

The reason to move Translation class is explained here [1]

[1] 106649a8a5
This commit is contained in:
Senén Rodero Rodríguez
2019-04-01 11:39:23 +02:00
committed by voodoorai2000
parent da1c5fdb01
commit c2f393276a

View File

@@ -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