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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user