|  | Commit message (Collapse) | Author | Age | Files | Lines | 
|---|
| | 
| 
| 
| 
| 
| 
| 
| | Remove trailing whitespace [ci skip]
Reword
Root value should be string [ci skip] | 
| | 
| 
| 
| 
| | According to doc the method should return
non-json compatible types as strings. | 
| | |  | 
| | 
| 
| 
| 
| | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa. | 
| | |  | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | * Allow a default value to be declared for class_attribute
* Convert to using class_attribute default rather than explicit setter
* Removed instance_accessor option by mistake
* False is a valid default value
* Documentation | 
| | |  | 
| | 
| 
| 
| 
| | The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default. | 
| | 
| 
| 
| 
| 
| 
| 
| 
| | Instance level writers can have an impact on how the Active Model /
Record objects are saved.  Specifically, they can be used to bypass
validations.  This is a problem if mass assignment protection is
disabled and specific attributes are passed to the constructor.
CVE-2016-0753 | 
| | 
| 
| 
| 
| | Commit d67b289 introduced a tiny regression in the docs for #from_json,
true needs to be included when the root node is present. | 
| | 
| 
| 
| 
| 
| | This allows rails code to be more confdent when asking for a model name, instead of having to ask for the class.
Rails core discussion here: https://groups.google.com/forum/#!topic/rubyonrails-core/ThSaXw9y1F8 | 
| | 
| 
| 
| | links in rdoc [ci skip] | 
| | 
| 
| | Dynamically setting instance variables based on user input probably isn't a great idea. Better to go through the setter methods provided by attr_accessor. | 
| | |  | 
| |\  
| | 
| | 
| | 
| | 
| | | Conflicts:
	activemodel/lib/active_model/secure_password.rb
	activerecord/lib/active_record/associations/collection_proxy.rb | 
| | | |  | 
| | | |  | 
| |/ |  | 
| | 
| 
| 
| | with this change root has always one assignment | 
| | 
| 
| 
| 
| | Get rid of ActiveModel::Configuration, make better use of
ActiveSupport::Concern + class_attribute, etc. | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | 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. | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | The problem: We need to be able to specify configuration in a way that
can be inherited to models that include ActiveRecord::Model. So it is
no longer sufficient to put 'top level' config on ActiveRecord::Base,
but we do want configuration specified on ActiveRecord::Base and
descendants to continue to work.
So we need something like class_attribute that can be defined on a
module but that is inherited when ActiveRecord::Model is included.
The solution: added ActiveModel::Configuration module which provides a
config_attribute macro. It's a bit specific hence I am not putting this
in Active Support or making it a 'public API' at present. | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | namespace."
This reverts commit 8896b4fdc8a543157cdf4dfc378607ebf6c10ab0.
Conflicts:
	activemodel/lib/active_model.rb
	activemodel/lib/active_model/serializable.rb
	activemodel/lib/active_model/serializer.rb
	activemodel/test/cases/serializer_test.rb | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | The following constants were renamed:
  ActiveModel::Serialization     => ActiveModel::Serializable
  ActiveModel::Serializers::JSON => ActiveModel::Serializable::JSON
  ActiveModel::Serializers::Xml  => ActiveModel::Serializable::XML
The main motivation for such a change is that `ActiveModel::Serializers::JSON`
was not actually a serializer, but a module that when included allows the target to be serializable to JSON.
With such changes, we were able to clean up the namespace to add true serializers as the ArraySerializer. | 
| | |  | 
| | |  | 
| | |  | 
| | 
| 
| 
| | include the root, but an instance is serialized with the root option passed as true | 
| | |  | 
| | |  | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| | - as_json in ActiveModel should return a hash
  and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument
[#5374 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> | 
| | |  | 
| | 
| 
| 
| | for the classes which includes this module | 
| | |  | 
| | |  | 
| | |  | 
| | |  | 
| | 
| 
| 
| 
| 
| | [#4515 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net> | 
| | 
| 
| 
| | 3 [DHH] | 
| | 
| 
| 
| | actual serializer | 
| | |  | 
| | |  | 
| | |  | 
| | |  | 
|  |  |