16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/globalize/model/active_record/translated.rb', line 16
def translates(*attr_names)
options = attr_names.
options[:translated_attributes] = attr_names
unless included_modules.include? InstanceMethods
class_inheritable_accessor :globalize_options, :globalize_proxy
include InstanceMethods
extend ClassMethods
metaclass.alias_method_chain :find_every, :globalize2
metaclass.alias_method_chain :construct_finder_sql, :globalize2
self.globalize_proxy = Globalize::Model::ActiveRecord.create_proxy_class(self)
has_many(
:globalize_translations,
:class_name => globalize_proxy.name,
:extend => Extensions,
:dependent => :delete_all,
:foreign_key => self.name.gsub(/.+::/, '').foreign_key
)
after_save :update_globalize_record
end
self.globalize_options = options
Globalize::Model::ActiveRecord.define_accessors(self, attr_names)
extend Callbacks
Callbacks.instance_methods.each {|cb| send cb }
end
|