Module: ActiveRecordTranslatable::ClassMethods

Defined in:
lib/activerecord_translatable/extension.rb

Instance Method Summary collapse

Instance Method Details

#translatableObject

Attributes defined as translatable



99
100
101
# File 'lib/activerecord_translatable/extension.rb', line 99

def translatable
  self._translatable[base_name] ||= []
end

#translate(*attributes) ⇒ Object

Define attribute as translatable

class Thing < ActiveRecord::Base
  translate :name
end


91
92
93
94
# File 'lib/activerecord_translatable/extension.rb', line 91

def translate(*attributes)
  self._translatable ||= Hash.new { |h,k| h[k] = [] }
  self._translatable[base_name] = translatable.concat(attributes).uniq
end