Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Jun 14, 2012
  1. Jan Berdajs
Commits on Jun 6, 2012
  1. Francesco Rodríguez

    change AMS::JSON.include_root_in_json default value to false

    frodsan authored
    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.
Commits on Jun 1, 2012
  1. Rafael Mendonça França
Commits on May 28, 2012
  1. Steve Purcell

    Don't enable validations when passing false hash values to ActiveMode…

    purcell authored
    …l.validates
    
    Passing a falsey option value for a validator currently causes that validator to
    be enabled, just like "true":
    
        ActiveModel.validates :foo, :presence => false
    
    This is rather counterintuitive, and makes it inconvenient to wrap `validates` in
    methods which may conditionally enable different validators.
    
    As an example, one is currently forced to write:
    
          def has_slug(source_field, options={:unique => true})
            slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
            before_validation slugger
            validations = { :presence => true, :slug => true }
            if options[:unique]
              validations[:uniqueness] = true
            end
            validates :slug, validations
          end
    
    because the following reasonable-looking alternative fails to work as expected:
    
          def has_slug(source_field, options={:unique => true})
            slugger = Proc.new { |r| r[:slug] = self.class.sluggify(r[source_field]) if r[:slug].blank? }
            before_validation slugger
            validates :slug, :presence => true, :slug => true, :uniqueness => options[:unique]
          end
    
    (This commit includes a test, and all activemodel and activerecord tests pass as before.)
Commits on Apr 24, 2012
  1. Brian Cardarella

    Reordered changelog entry

    bcardarella authored
  2. Brian Cardarella

    Updated CHANGELOG

    bcardarella authored
Commits on Mar 9, 2012
  1. Rafael Mendonça França

    Fix my name in the CHANGELOG to follow the convention

    rafaelfranca authored
    Also add missing entries and use the formating convention
Commits on Mar 8, 2012
  1. Vijay Dev
Commits on Mar 3, 2012
  1. Guillermo Iguaran
Commits on Mar 1, 2012
  1. Claudio B.

    Add release dates to documentation

    claudiob authored
    Set "March 1, 2012" as the release date for 3.2.2, 3.1.4, 3.0.12
Commits on Feb 25, 2012
  1. Paco Guzmán

    Update changelogs with rails 3.0-stable branch info

    pacoguzman authored pacoguzman committed
Commits on Feb 20, 2012
  1. Bogdan Gusiev
Commits on Feb 7, 2012
  1. José Valim
Commits on Jan 26, 2012
  1. Claudio B.
Commits on Nov 30, 2011
  1. José Valim

    Revert "Implement ArraySerializer and move old serialization API to a…

    josevalim authored
    … new namespace."
    
    This reverts commit 8896b4f.
    
    Conflicts:
    
    	activemodel/lib/active_model.rb
    	activemodel/lib/active_model/serializable.rb
    	activemodel/lib/active_model/serializer.rb
    	activemodel/test/cases/serializer_test.rb
Commits on Nov 29, 2011
  1. Jon Leighton

    Deprecated `define_attr_method` in `ActiveModel::AttributeMethods`

    jonleighton authored
    This only existed to support methods like `set_table_name` in Active
    Record, which are themselves being deprecated.
Commits on Nov 25, 2011
  1. José Valim
  2. José Valim
Commits on Nov 4, 2011
  1. Jon Leighton

    Convert CHANGELOGs to Markdown format.

    jonleighton authored
    Reasons:
    
     * Markdown reads well as plain text, but can also be formatted.
     * It will make it easier for people to read on the web as Github
       formats the Markdown nicely.
     * It will encourage a level of consistency when people are writing
       CHANGELOG entries.
    
    The script used to perform the conversion is at
    https://gist.github.com/1339263
Something went wrong with that request. Please try again.