Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/attribute_translator/active_record/base.rb
Class Method Summary collapse
Class Method Details
.translates(*attributes) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/attribute_translator/active_record/base.rb', line 3 def self.translates(*attributes) attributes.each do |attribute| define_method attribute do value = send("#{attribute}_before_type_cast") begin I18n.t(value, :scope => "activerecord.values.#{self.class.name.underscore}.#{attribute}") rescue value end end end end |