# == Schema Information # # Table name: legals # # id :bigint not null, primary key # position :integer # is_visible :boolean default(“true”) # created_at :datetime not null # updated_at :datetime not null # class Legal < ApplicationRecord
include LogActions has_many :legal_translations, dependent: :destroy accepts_nested_attributes_for :legal_translations include TranslationsInitializer def to_param "#{self.legal_translations.find_by(language_id: I18n.locale).title.parameterize}" end def translate(language_id=I18n.locale.to_s) # commented code can be to added to app/models/concerns/translation_initializer.rb # so other models can use it #def translate(language_id=I18n.locale.to_s) # translations = eval("#{self.model_name.param_key}_translations") # translations.find_by(language_id: language_id) #end legal_translations.find_by(language_id: language_id) end
end