Module: RailsExtend::ActiveRecord::Translation
- Defined in:
- lib/rails_extend/active_record/translation.rb
Instance Method Summary collapse
- #_update_record(values, constraints) ⇒ Object
-
#has_translations(*columns) ⇒ Object
name * store as jsonb in database; * read with i18n scope.
Instance Method Details
#_update_record(values, constraints) ⇒ Object
31 32 33 34 |
# File 'lib/rails_extend/active_record/translation.rb', line 31 def _update_record(values, constraints) values.except!(*i18n_attributes) if self.respond_to?(:i18n_attributes) super end |
#has_translations(*columns) ⇒ Object
name
- store as jsonb in database;
- read with i18n scope
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_extend/active_record/translation.rb', line 9 def has_translations(*columns) mattr_accessor :i18n_attributes self.i18n_attributes = columns.map(&:to_s) include RailsCom::I18n columns.each do |column| attribute column, :i18n class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{column}=(value) if value.is_a?(String) super(::I18n.locale.to_s => value) else super end end RUBY_EVAL end end |