orbit-basic/config/initializers/mongoid.rb

17 lines
359 B
Ruby

def field_i18n(field, *options)
['en', 'zh_tw'].each do |locale|
field "#{field.to_s}_#{locale}".to_sym, *options
end
define_method(field) do
self.send("#{field.to_s}_#{I18n.locale}")
end
define_method("#{field}=") do |value|
['en', 'zh_tw'].each do |locale|
self.send("#{field.to_s}_#{locale}=", value)
end
end
end