From 59478ef46188c9929d36bbd6bc558744dca304b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 8 Aug 2019 18:27:41 +0200 Subject: [PATCH] Remove duplicate Translation classes We accidentally added them twice when rebasing the translations branch. --- app/models/budget.rb | 12 ------------ app/models/budget/group.rb | 14 -------------- app/models/budget/heading.rb | 15 --------------- 3 files changed, 41 deletions(-) diff --git a/app/models/budget.rb b/app/models/budget.rb index 4904f3923..c4fe62eeb 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -229,16 +229,4 @@ class Budget < ApplicationRecord slug.nil? || drafting? 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 diff --git a/app/models/budget/group.rb b/app/models/budget/group.rb index 741040c78..71eebb308 100644 --- a/app/models/budget/group.rb +++ b/app/models/budget/group.rb @@ -39,19 +39,5 @@ class Budget def generate_slug? 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 diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb index 0221061d7..0e218d6fb 100644 --- a/app/models/budget/heading.rb +++ b/app/models/budget/heading.rb @@ -59,20 +59,5 @@ class Budget def generate_slug? 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.headings - .joins(:translations) - .where(name: name) - .where.not("budget_heading_translations.budget_heading_id": budget_heading_id).any? - errors.add(:name, I18n.t("errors.messages.taken")) - end - end - end end end