From 1ba50c76c4e1f59ba9101fd0dbe1df9e5d35962b Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Wed, 6 Feb 2019 18:09:41 +0100 Subject: [PATCH] Use method from Globalizable module Since we have a method defined inside the Globalizable module we don't need to create the same method in every model --- app/models/milestone.rb | 7 +------ app/models/progress_bar.rb | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 5abd5cb4f..d4ef41137 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -14,7 +14,7 @@ class Milestone < ActiveRecord::Base validates :milestoneable, presence: true validates :publication_date, presence: true - before_validation :assign_milestone_to_translations + before_validation :assign_model_to_translations validates_translation :description, presence: true, unless: -> { status_id.present? } scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) } @@ -25,9 +25,4 @@ class Milestone < ActiveRecord::Base 80 end - private - - def assign_milestone_to_translations - translations.each { |translation| translation.globalized_model = self } - end end diff --git a/app/models/progress_bar.rb b/app/models/progress_bar.rb index 7a7973723..2f494196e 100644 --- a/app/models/progress_bar.rb +++ b/app/models/progress_bar.rb @@ -17,12 +17,7 @@ class ProgressBar < ActiveRecord::Base } validates :percentage, presence: true, inclusion: RANGE, numericality: { only_integer: true } - before_validation :assign_progress_bar_to_translations + before_validation :assign_model_to_translations validates_translation :title, presence: true, unless: :primary? - private - - def assign_progress_bar_to_translations - translations.each { |translation| translation.globalized_model = self } - end end