lib/mongoid/i18n.rb in mongoid_i18n-0.1.6 vs lib/mongoid/i18n.rb in mongoid_i18n-0.1.7

- old
+ new

@@ -18,10 +18,15 @@ protected def create_accessors(name, meth, options = {}) if options[:type] == LocalizedField define_method(meth) { read_attribute(name)[::I18n.locale.to_s] rescue '' } define_method("#{meth}=") do |value| - write_attribute(name, (@attributes[name] || {}).merge(::I18n.locale.to_s => value)) + if value.is_a?(Hash) + val = (@attributes[name] || {}).merge(value) + else + val = (@attributes[name] || {}).merge(::I18n.locale.to_s => value) + end + write_attribute(name, val) end define_method("#{meth}_translations") { read_attribute(name) } define_method("#{meth}_translations=") { |value| write_attribute(name, value) } else super \ No newline at end of file