This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/config/initializers/mongoid.rb

17 lines
359 B
Ruby
Raw Normal View History

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