aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/locking_test.rb
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-06 01:11:39 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-06-06 01:11:39 -0500
commitab11a2780fe8e059ffc8824df18037773a4f5200 (patch)
treee189a76ed6c5d743b8b99d5577c0a7a01ed9862c /activerecord/test/cases/locking_test.rb
parentd10eb699649f9d7fa7e51ae1b633545d6a55e1ad (diff)
downloadrails-ab11a2780fe8e059ffc8824df18037773a4f5200.tar.gz
rails-ab11a2780fe8e059ffc8824df18037773a4f5200.tar.bz2
rails-ab11a2780fe8e059ffc8824df18037773a4f5200.zip
change AMS::JSON.include_root_in_json default value to false
Changes: * Update `include_root_in_json` default value to false for default value to false for `ActiveModel::Serializers::JSON`. * Remove unnecessary change to include_root_in_json option in wrap_parameters template. * Update `as_json` documentation. * Fix JSONSerialization tests. Problem: It's confusing that AM serializers behave differently from AR, even when AR objects include AM serializers module. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"person"=>{"name"=>"Francesco", "age"=>22}} # root is included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => true # different default values for include_root_in_json Proposal: Change the default value of AM serializers to false, update the misleading documentation and remove unnecessary change to false of include_root_in_json option with AR objects. class User < ActiveRecord::Base; end class Person include ActiveModel::Model include ActiveModel::AttributeMethods include ActiveModel::Serializers::JSON attr_accessor :name, :age def attributes instance_values end end user.as_json => {"id"=>1, "name"=>"Konata Izumi", "age"=>16, "awesome"=>true} # root is not included person.as_json => {"name"=>"Francesco", "age"=>22} # root is not included ActiveRecord::Base.include_root_in_json => false Person.include_root_in_json => false # same behaviour, more consistent Fixes #6578.
Diffstat (limited to 'activerecord/test/cases/locking_test.rb')
0 files changed, 0 insertions, 0 deletions