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
This commit is contained in:
Julian Herrero
2019-02-06 18:09:41 +01:00
parent 922600252c
commit 1ba50c76c4
2 changed files with 2 additions and 12 deletions

View File

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

View File

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