ruby - Store stops working when upgrading to Rails 4.0 from 3.2 -


i upgrading rails application v3.2 v4.0. in user model have json coded store:

store :settings, accessors: [   :confirmed,   :receive_marketing_emails,   :receive_reply_emails ], coder: json 

this works expected, serializing user.settings , providing accessors.

however when move rails 4.0 store stops working. following error when attempt user:

json::parsererror: 795: unexpected token @ '--- :confirmed, :receive_marketing_emails, :receive_reply_emails ' 

can provide insight?

there statement in rails upgrade guide:

rails 4.0 has changed activemodel::serializers::json.include_root_in_json default value false. now, active model serializers , active record objects have same default behavior.

i'd suggest when accessing user instance, json field cannot deserialized since expects no root, while serialized data has it.

to revert rails 3.2 behaviour, put in config/initializers/wrap_parameters.rb:

activesupport.on_load(:active_record)   self.include_root_in_json = true end 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -