4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/globalize/active_record/act_macro.rb', line 4
def translates(*attr_names)
return if translates?
options = attr_names.
options[:table_name] ||= "#{table_name.singularize}_translations"
class_inheritable_accessor :translated_attribute_names, :translation_options
self.translated_attribute_names = attr_names.map(&:to_sym)
self.translation_options = options
include InstanceMethods
extend ClassMethods, Migration
has_many :translations, :class_name => translation_class.name,
:foreign_key => class_name.foreign_key,
:dependent => :delete_all,
:extend => HasManyExtensions
after_save :save_translations!
attr_names.each { |attr_name| translated_attr_accessor(attr_name) }
end
|