bithavoc / multilang-hstore

Multilang is a small library for translating database values for Rails 4 and Postgresql hstore
MIT License
41 stars 18 forks source link

Fix. MultilangTranslationProxy assignment. #9

Closed proAlexandr closed 8 years ago

proAlexandr commented 9 years ago

Fix the bug of assignment a MultilangTranslationProxy to multilang attribute.

It can fix this case.

class City < ActiveRecord::Base
  multilang :name
end

serialized_record = YAML.dump city.name
city.name = YAML.load serialized_record

serialized_record stores the serialized instance of MultilangTranslationProxy. YAML.load return the instance of MultilangTranslationProxy. After the evaluation of 'city.name = YAML.load serialized_record' city.name will become a blank string because city.name= can't take a argument with MultilangTranslationProxy type.