From 3c580182ff3c16d2247aabc85100bf8c6edb0f82 Mon Sep 17 00:00:00 2001
From: AvnerCohen <israbirding@gmail.com>
Date: Thu, 8 Nov 2012 23:16:54 +0200
Subject: 1.9 hash syntax changes

---
 activerecord/lib/active_record/aggregations.rb     |  36 +++----
 activerecord/lib/active_record/associations.rb     | 106 ++++++++++-----------
 .../lib/active_record/autosave_association.rb      |  22 ++---
 activerecord/lib/active_record/base.rb             |  38 ++++----
 activerecord/lib/active_record/callbacks.rb        |   2 +-
 .../lib/active_record/connection_handling.rb       |  16 ++--
 activerecord/lib/active_record/core.rb             |   2 +-
 7 files changed, 111 insertions(+), 111 deletions(-)

(limited to 'activerecord')

diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 3db8e0716b..8101f7a45e 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -16,8 +16,8 @@ module ActiveRecord
     # the database).
     #
     #   class Customer < ActiveRecord::Base
-    #     composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
-    #     composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ]
+    #     composed_of :balance, class_name: "Money", mapping: %w(balance amount)
+    #     composed_of :address, mapping: [ %w(address_street street), %w(address_city city) ]
     #   end
     #
     # The customer class now has the following methods to manipulate the value objects:
@@ -138,15 +138,15 @@ module ActiveRecord
     #
     #   class NetworkResource < ActiveRecord::Base
     #     composed_of :cidr,
-    #                 :class_name => 'NetAddr::CIDR',
-    #                 :mapping => [ %w(network_address network), %w(cidr_range bits) ],
-    #                 :allow_nil => true,
-    #                 :constructor => Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") },
-    #                 :converter => Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) }
+    #                 class_name: 'NetAddr::CIDR',
+    #                 mapping: [ %w(network_address network), %w(cidr_range bits) ],
+    #                 allow_nil: true,
+    #                 constructor: Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") },
+    #                 converter: Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) }
     #   end
     #
     #   # This calls the :constructor
-    #   network_resource = NetworkResource.new(:network_address => '192.168.0.1', :cidr_range => 24)
+    #   network_resource = NetworkResource.new(network_address: '192.168.0.1', cidr_range: 24)
     #
     #   # These assignments will both use the :converter
     #   network_resource.cidr = [ '192.168.2.1', 8 ]
@@ -165,7 +165,7 @@ module ActiveRecord
     # by specifying an instance of the value object in the conditions hash. The following example
     # finds all customers with +balance_amount+ equal to 20 and +balance_currency+ equal to "USD":
     #
-    #   Customer.where(:balance => Money.new(20, "USD")).all
+    #   Customer.where(balance: Money.new(20, "USD")).all
     #
     module ClassMethods
       # Adds reader and writer methods for manipulating a value object:
@@ -197,17 +197,17 @@ module ActiveRecord
       #   can return nil to skip the assignment.
       #
       # Option examples:
-      #   composed_of :temperature, :mapping => %w(reading celsius)
-      #   composed_of :balance, :class_name => "Money", :mapping => %w(balance amount),
-      #                         :converter => Proc.new { |balance| balance.to_money }
-      #   composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ]
+      #   composed_of :temperature, mapping: %w(reading celsius)
+      #   composed_of :balance, class_name: "Money", mapping: %w(balance amount),
+      #                         converter: Proc.new { |balance| balance.to_money }
+      #   composed_of :address, mapping: [ %w(address_street street), %w(address_city city) ]
       #   composed_of :gps_location
-      #   composed_of :gps_location, :allow_nil => true
+      #   composed_of :gps_location, allow_nil: true
       #   composed_of :ip_address,
-      #               :class_name => 'IPAddr',
-      #               :mapping => %w(ip to_i),
-      #               :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) },
-      #               :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) }
+      #               class_name: 'IPAddr',
+      #               mapping: %w(ip to_i),
+      #               constructor: Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) },
+      #               converter: Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) }
       #
       def composed_of(part_id, options = {})
         options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter)
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 69b95f814c..7a59da091d 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -305,11 +305,11 @@ module ActiveRecord
     #   end
     #   class Programmer < ActiveRecord::Base
     #     has_many :assignments
-    #     has_many :projects, :through => :assignments
+    #     has_many :projects, through: :assignments
     #   end
     #   class Project < ActiveRecord::Base
     #     has_many :assignments
-    #     has_many :programmers, :through => :assignments
+    #     has_many :programmers, through: :assignments
     #   end
     #
     # For the second way, use +has_and_belongs_to_many+ in both models. This requires a join table
@@ -426,7 +426,7 @@ module ActiveRecord
     # object from an association collection.
     #
     #   class Project
-    #     has_and_belongs_to_many :developers, :after_add => :evaluate_velocity
+    #     has_and_belongs_to_many :developers, after_add: :evaluate_velocity
     #
     #     def evaluate_velocity(developer)
     #       ...
@@ -437,7 +437,7 @@ module ActiveRecord
     #
     #   class Project
     #     has_and_belongs_to_many :developers,
-    #                             :after_add => [:evaluate_velocity, Proc.new { |p, d| p.shipping_date = Time.now}]
+    #                             after_add: [:evaluate_velocity, Proc.new { |p, d| p.shipping_date = Time.now}]
     #   end
     #
     # Possible callbacks are: +before_add+, +after_add+, +before_remove+ and +after_remove+.
@@ -507,7 +507,7 @@ module ActiveRecord
     #
     #   class Author < ActiveRecord::Base
     #     has_many :authorships
-    #     has_many :books, :through => :authorships
+    #     has_many :books, through: :authorships
     #   end
     #
     #   class Authorship < ActiveRecord::Base
@@ -523,7 +523,7 @@ module ActiveRecord
     #
     #   class Firm < ActiveRecord::Base
     #     has_many   :clients
-    #     has_many   :invoices, :through => :clients
+    #     has_many   :invoices, through: :clients
     #   end
     #
     #   class Client < ActiveRecord::Base
@@ -543,7 +543,7 @@ module ActiveRecord
     #
     #   class Group < ActiveRecord::Base
     #     has_many   :users
-    #     has_many   :avatars, :through => :users
+    #     has_many   :avatars, through: :users
     #   end
     #
     #   class User < ActiveRecord::Base
@@ -571,7 +571,7 @@ module ActiveRecord
     # works correctly (where <tt>tags</tt> is a +has_many+ <tt>:through</tt> association):
     #
     #   @post = Post.first
-    #   @tag = @post.tags.build :name => "ruby"
+    #   @tag = @post.tags.build name: "ruby"
     #   @tag.save
     #
     # The last line ought to save the through record (a <tt>Taggable</tt>). This will only work if the
@@ -579,7 +579,7 @@ module ActiveRecord
     #
     #   class Taggable < ActiveRecord::Base
     #     belongs_to :post
-    #     belongs_to :tag, :inverse_of => :taggings
+    #     belongs_to :tag, inverse_of: :taggings
     #   end
     #
     # == Nested Associations
@@ -589,8 +589,8 @@ module ActiveRecord
     #
     #   class Author < ActiveRecord::Base
     #     has_many :posts
-    #     has_many :comments, :through => :posts
-    #     has_many :commenters, :through => :comments
+    #     has_many :comments, through: :posts
+    #     has_many :commenters, through: :comments
     #   end
     #
     #   class Post < ActiveRecord::Base
@@ -608,12 +608,12 @@ module ActiveRecord
     #
     #   class Author < ActiveRecord::Base
     #     has_many :posts
-    #     has_many :commenters, :through => :posts
+    #     has_many :commenters, through: :posts
     #   end
     #
     #   class Post < ActiveRecord::Base
     #     has_many :comments
-    #     has_many :commenters, :through => :comments
+    #     has_many :commenters, through: :comments
     #   end
     #
     #   class Comment < ActiveRecord::Base
@@ -632,11 +632,11 @@ module ActiveRecord
     # must adhere to.
     #
     #   class Asset < ActiveRecord::Base
-    #     belongs_to :attachable, :polymorphic => true
+    #     belongs_to :attachable, polymorphic: true
     #   end
     #
     #   class Post < ActiveRecord::Base
-    #     has_many :assets, :as => :attachable         # The :as option specifies the polymorphic interface to use.
+    #     has_many :assets, as: :attachable         # The :as option specifies the polymorphic interface to use.
     #   end
     #
     #   @asset.attachable = @post
@@ -653,7 +653,7 @@ module ActiveRecord
     # column in the posts table.
     #
     #   class Asset < ActiveRecord::Base
-    #     belongs_to :attachable, :polymorphic => true
+    #     belongs_to :attachable, polymorphic: true
     #
     #     def attachable_type=(sType)
     #        super(sType.to_s.classify.constantize.base_class.to_s)
@@ -661,8 +661,8 @@ module ActiveRecord
     #   end
     #
     #   class Post < ActiveRecord::Base
-    #     # because we store "Post" in attachable_type now :dependent => :destroy will work
-    #     has_many :assets, :as => :attachable, :dependent => :destroy
+    #     # because we store "Post" in attachable_type now dependent: :destroy will work
+    #     has_many :assets, as: :attachable, dependent: :destroy
     #   end
     #
     #   class GuestPost < Post
@@ -724,7 +724,7 @@ module ActiveRecord
     #
     # To include a deep hierarchy of associations, use a hash:
     #
-    #   Post.includes(:author, {:comments => {:author => :gravatar}}).each do |post|
+    #   Post.includes(:author, {comments: {author: :gravatar}}).each do |post|
     #
     # That'll grab not only all the comments but all their authors and gravatar pictures.
     # You can mix and match symbols, arrays and hashes in any combination to describe the
@@ -749,13 +749,13 @@ module ActiveRecord
     # In the above example posts with no approved comments are not returned at all, because
     # the conditions apply to the SQL statement as a whole and not just to the association.
     # You must disambiguate column references for this fallback to happen, for example
-    # <tt>:order => "author.name DESC"</tt> will work but <tt>:order => "name DESC"</tt> will not.
+    # <tt>order: "author.name DESC"</tt> will work but <tt>order: "name DESC"</tt> will not.
     #
     # If you do want eager load only some members of an association it is usually more natural
     # to include an association which has conditions defined on it:
     #
     #   class Post < ActiveRecord::Base
-    #     has_many :approved_comments, -> { where approved: true }, :class_name => 'Comment'
+    #     has_many :approved_comments, -> { where approved: true }, class_name: 'Comment'
     #   end
     #
     #   Post.includes(:approved_comments)
@@ -767,7 +767,7 @@ module ActiveRecord
     # returning all the associated objects:
     #
     #   class Picture < ActiveRecord::Base
-    #     has_many :most_recent_comments, -> { order('id DESC').limit(10) }, :class_name => 'Comment'
+    #     has_many :most_recent_comments, -> { order('id DESC').limit(10) }, class_name: 'Comment'
     #   end
     #
     #   Picture.includes(:most_recent_comments).first.most_recent_comments # => returns all associated comments.
@@ -775,7 +775,7 @@ module ActiveRecord
     # Eager loading is supported with polymorphic associations.
     #
     #   class Address < ActiveRecord::Base
-    #     belongs_to :addressable, :polymorphic => true
+    #     belongs_to :addressable, polymorphic: true
     #   end
     #
     # A call that tries to eager load the addressable model
@@ -809,10 +809,10 @@ module ActiveRecord
     #
     #   TreeMixin.joins(:children)
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
-    #   TreeMixin.joins(:children => :parent)
+    #   TreeMixin.joins(children: :parent)
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
     #                               INNER JOIN parents_mixins ...
-    #   TreeMixin.joins(:children => {:parent => :children})
+    #   TreeMixin.joins(children: {parent: :children})
     #   # => SELECT ... FROM mixins INNER JOIN mixins childrens_mixins ...
     #                               INNER JOIN parents_mixins ...
     #                               INNER JOIN mixins childrens_mixins_2
@@ -821,10 +821,10 @@ module ActiveRecord
     #
     #   Post.joins(:categories)
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
-    #   Post.joins(:categories => :posts)
+    #   Post.joins(categories: :posts)
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
     #                              INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories
-    #   Post.joins(:categories => {:posts => :categories})
+    #   Post.joins(categories: {posts: :categories})
     #   # => SELECT ... FROM posts INNER JOIN categories_posts ... INNER JOIN categories ...
     #                              INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories
     #                              INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2
@@ -868,7 +868,7 @@ module ActiveRecord
     #
     #     module Billing
     #       class Account < ActiveRecord::Base
-    #         belongs_to :firm, :class_name => "MyApplication::Business::Firm"
+    #         belongs_to :firm, class_name: "MyApplication::Business::Firm"
     #       end
     #     end
     #   end
@@ -910,16 +910,16 @@ module ActiveRecord
     # example, if we changed our model definitions to:
     #
     #    class Dungeon < ActiveRecord::Base
-    #      has_many :traps, :inverse_of => :dungeon
-    #      has_one :evil_wizard, :inverse_of => :dungeon
+    #      has_many :traps, inverse_of: :dungeon
+    #      has_one :evil_wizard, inverse_of: :dungeon
     #    end
     #
     #    class Trap < ActiveRecord::Base
-    #      belongs_to :dungeon, :inverse_of => :traps
+    #      belongs_to :dungeon, inverse_of: :traps
     #    end
     #
     #    class EvilWizard < ActiveRecord::Base
-    #      belongs_to :dungeon, :inverse_of => :evil_wizard
+    #      belongs_to :dungeon, inverse_of: :evil_wizard
     #    end
     #
     # Then, from our code snippet above, +d+ and <tt>t.dungeon</tt> are actually the same
@@ -942,7 +942,7 @@ module ActiveRecord
     # For example:
     #
     #     class Author
-    #       has_many :posts, :dependent => :destroy
+    #       has_many :posts, dependent: :destroy
     #     end
     #     Author.find(1).destroy # => Will destroy all of the author's posts, too
     #
@@ -1026,12 +1026,12 @@ module ActiveRecord
       #   parent object.
       # [collection.delete(object, ...)]
       #   Removes one or more objects from the collection by setting their foreign keys to +NULL+.
-      #   Objects will be in addition destroyed if they're associated with <tt>:dependent => :destroy</tt>,
-      #   and deleted if they're associated with <tt>:dependent => :delete_all</tt>.
+      #   Objects will be in addition destroyed if they're associated with <tt>dependent: :destroy</tt>,
+      #   and deleted if they're associated with <tt>dependent: :delete_all</tt>.
       #
       #   If the <tt>:through</tt> option is used, then the join records are deleted (rather than
-      #   nullified) by default, but you can specify <tt>:dependent => :destroy</tt> or
-      #   <tt>:dependent => :nullify</tt> to override this.
+      #   nullified) by default, but you can specify <tt>dependent: :destroy</tt> or
+      #   <tt>dependent: :nullify</tt> to override this.
       # [collection.destroy(object, ...)]
       #   Removes one or more objects from the collection by running <tt>destroy</tt> on
       #   each record, regardless of any dependent option, ensuring callbacks are run.
@@ -1049,8 +1049,8 @@ module ActiveRecord
       #   method loads the models and calls <tt>collection=</tt>. See above.
       # [collection.clear]
       #   Removes every object from the collection. This destroys the associated objects if they
-      #   are associated with <tt>:dependent => :destroy</tt>, deletes them directly from the
-      #   database if <tt>:dependent => :delete_all</tt>, otherwise sets their foreign keys to +NULL+.
+      #   are associated with <tt>dependent: :destroy</tt>, deletes them directly from the
+      #   database if <tt>dependent: :delete_all</tt>, otherwise sets their foreign keys to +NULL+.
       #   If the <tt>:through</tt> option is true no destroy callbacks are invoked on the join models.
       #   Join models are directly deleted.
       # [collection.empty?]
@@ -1078,7 +1078,7 @@ module ActiveRecord
       # === Example
       #
       # Example: A Firm class declares <tt>has_many :clients</tt>, which will add:
-      # * <tt>Firm#clients</tt> (similar to <tt>Clients.all :conditions => ["firm_id = ?", id]</tt>)
+      # * <tt>Firm#clients</tt> (similar to <tt>Clients.all conditions: ["firm_id = ?", id]</tt>)
       # * <tt>Firm#clients<<</tt>
       # * <tt>Firm#clients.delete</tt>
       # * <tt>Firm#clients.destroy</tt>
@@ -1088,8 +1088,8 @@ module ActiveRecord
       # * <tt>Firm#clients.clear</tt>
       # * <tt>Firm#clients.empty?</tt> (similar to <tt>firm.clients.size == 0</tt>)
       # * <tt>Firm#clients.size</tt> (similar to <tt>Client.count "firm_id = #{id}"</tt>)
-      # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find(id, :conditions => "firm_id = #{id}")</tt>)
-      # * <tt>Firm#clients.exists?(:name => 'ACME')</tt> (similar to <tt>Client.exists?(:name => 'ACME', :firm_id => firm.id)</tt>)
+      # * <tt>Firm#clients.find</tt> (similar to <tt>Client.find(id, conditions: "firm_id = #{id}")</tt>)
+      # * <tt>Firm#clients.exists?(name: 'ACME')</tt> (similar to <tt>Client.exists?(name: 'ACME', firm_id: firm.id)</tt>)
       # * <tt>Firm#clients.build</tt> (similar to <tt>Client.new("firm_id" => id)</tt>)
       # * <tt>Firm#clients.create</tt> (similar to <tt>c = Client.new("firm_id" => id); c.save; c</tt>)
       # The declaration can also include an options hash to specialize the behavior of the association.
@@ -1143,7 +1143,7 @@ module ActiveRecord
       # [:source]
       #   Specifies the source association name used by <tt>has_many :through</tt> queries.
       #   Only use it if the name cannot be inferred from the association.
-      #   <tt>has_many :subscribers, :through => :subscriptions</tt> will look for either <tt>:subscribers</tt> or
+      #   <tt>has_many :subscribers, through: :subscriptions</tt> will look for either <tt>:subscribers</tt> or
       #   <tt>:subscriber</tt> on Subscription, unless a <tt>:source</tt> is given.
       # [:source_type]
       #   Specifies type of the source association used by <tt>has_many :through</tt> queries where the source
@@ -1207,7 +1207,7 @@ module ActiveRecord
       # === Example
       #
       # An Account class declares <tt>has_one :beneficiary</tt>, which will add:
-      # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.first(:conditions => "account_id = #{id}")</tt>)
+      # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.first(conditions: "account_id = #{id}")</tt>)
       # * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>)
       # * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>)
       # * <tt>Account#create_beneficiary</tt> (similar to <tt>b = Beneficiary.new("account_id" => id); b.save; b</tt>)
@@ -1247,7 +1247,7 @@ module ActiveRecord
       # [:source]
       #   Specifies the source association name used by <tt>has_one :through</tt> queries.
       #   Only use it if the name cannot be inferred from the association.
-      #   <tt>has_one :favorite, :through => :favorites</tt> will look for a
+      #   <tt>has_one :favorite, through: :favorites</tt> will look for a
       #   <tt>:favorite</tt> on Favorite, unless a <tt>:source</tt> is given.
       # [:source_type]
       #   Specifies type of the source association used by <tt>has_one :through</tt> queries where the source
@@ -1267,11 +1267,11 @@ module ActiveRecord
       #   See ActiveRecord::Associations::ClassMethods's overview on Bi-directional associations for more detail.
       #
       # Option examples:
-      #   has_one :credit_card, :dependent => :destroy  # destroys the associated credit card
-      #   has_one :credit_card, :dependent => :nullify  # updates the associated records foreign
+      #   has_one :credit_card, dependent: :destroy  # destroys the associated credit card
+      #   has_one :credit_card, dependent: :nullify  # updates the associated records foreign
       #                                                 # key value to NULL rather than destroying it
-      #   has_one :last_comment, -> { order 'posted_on' }, :class_name => "Comment"
-      #   has_one :project_manager, -> { where role: 'project_manager' }, :class_name => "Person"
+      #   has_one :last_comment, -> { order 'posted_on' }, class_name: "Comment"
+      #   has_one :project_manager, -> { where role: 'project_manager' }, class_name: "Person"
       #   has_one :attachment, as: :attachable
       #   has_one :boss, readonly: :true
       #   has_one :club, through: :membership
@@ -1326,12 +1326,12 @@ module ActiveRecord
       #   Specify the foreign key used for the association. By default this is guessed to be the name
       #   of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt>
       #   association will use "person_id" as the default <tt>:foreign_key</tt>. Similarly,
-      #   <tt>belongs_to :favorite_person, :class_name => "Person"</tt> will use a foreign key
+      #   <tt>belongs_to :favorite_person, class_name: "Person"</tt> will use a foreign key
       #   of "favorite_person_id".
       # [:foreign_type]
       #   Specify the column used to store the associated object's type, if this is a polymorphic
       #   association. By default this is guessed to be the name of the association with a "_type"
-      #   suffix. So a class that defines a <tt>belongs_to :taggable, :polymorphic => true</tt>
+      #   suffix. So a class that defines a <tt>belongs_to :taggable, polymorphic: true</tt>
       #   association will use "taggable_type" as the default <tt>:foreign_type</tt>.
       # [:primary_key]
       #   Specify the method that returns the primary key of associated object used for the association.
@@ -1351,7 +1351,7 @@ module ActiveRecord
       #   <tt>#{table_name}_count</tt> is created on the associate class (such that Post.comments_count will
       #   return the count cached, see note below). You can also specify a custom counter
       #   cache column by providing a column name instead of a +true+/+false+ value to this
-      #   option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.)
+      #   option (e.g., <tt>counter_cache: :my_custom_counter</tt>.)
       #   Note: Specifying a counter cache will add it to that model's list of readonly attributes
       #   using +attr_readonly+.
       # [:polymorphic]
@@ -1409,7 +1409,7 @@ module ActiveRecord
       #
       #   class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration
       #     def change
-      #       create_table :developers_projects, :id => false do |t|
+      #       create_table :developers_projects, id: false do |t|
       #         t.integer :developer_id
       #         t.integer :project_id
       #       end
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index a30f888a7a..907fe70522 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -16,7 +16,7 @@ module ActiveRecord
   # Note that it also means that associations marked for destruction won't
   # be destroyed directly. They will however still be marked for destruction.
   #
-  # Note that <tt>:autosave => false</tt> is not same as not declaring <tt>:autosave</tt>.
+  # Note that <tt>autosave: false</tt> is not same as not declaring <tt>:autosave</tt>.
   # When the <tt>:autosave</tt> option is not present new associations are saved.
   #
   # == Validation
@@ -37,7 +37,7 @@ module ActiveRecord
   # === One-to-one Example
   #
   #   class Post
-  #     has_one :author, :autosave => true
+  #     has_one :author, autosave: true
   #   end
   #
   # Saving changes to the parent and its associated model can now be performed
@@ -81,27 +81,27 @@ module ActiveRecord
   #     has_many :comments # :autosave option is not declared
   #   end
   #
-  #   post = Post.new(:title => 'ruby rocks')
-  #   post.comments.build(:body => 'hello world')
+  #   post = Post.new(title: 'ruby rocks')
+  #   post.comments.build(body: 'hello world')
   #   post.save # => saves both post and comment
   #
-  #   post = Post.create(:title => 'ruby rocks')
-  #   post.comments.build(:body => 'hello world')
+  #   post = Post.create(title: 'ruby rocks')
+  #   post.comments.build(body: 'hello world')
   #   post.save # => saves both post and comment
   #
-  #   post = Post.create(:title => 'ruby rocks')
-  #   post.comments.create(:body => 'hello world')
+  #   post = Post.create(title: 'ruby rocks')
+  #   post.comments.create(body: 'hello world')
   #   post.save # => saves both post and comment
   #
   # When <tt>:autosave</tt> is true all children are saved, no matter whether they
   # are new records or not:
   #
   #   class Post
-  #     has_many :comments, :autosave => true
+  #     has_many :comments, autosave: true
   #   end
   #
-  #   post = Post.create(:title => 'ruby rocks')
-  #   post.comments.create(:body => 'hello world')
+  #   post = Post.create(title: 'ruby rocks')
+  #   post.comments.create(body: 'hello world')
   #   post.comments[0].body = 'hi everyone'
   #   post.save # => saves both post and comment, with 'hi everyone' as body
   #
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index eabbd80f66..a028e04044 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -36,7 +36,7 @@ module ActiveRecord #:nodoc:
   # method is especially useful when you're receiving the data from somewhere else, like an
   # HTTP request. It works like this:
   #
-  #   user = User.new(:name => "David", :occupation => "Code Artist")
+  #   user = User.new(name: "David", occupation: "Code Artist")
   #   user.name # => "David"
   #
   # You can also use block initialization:
@@ -69,7 +69,7 @@ module ActiveRecord #:nodoc:
   #     end
   #
   #     def self.authenticate_safely_simply(user_name, password)
-  #       where(:user_name => user_name, :password => password).first
+  #       where(user_name: user_name, password: password).first
   #     end
   #   end
   #
@@ -87,27 +87,27 @@ module ActiveRecord #:nodoc:
   #
   #   Company.where(
   #     "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
-  #     { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
+  #     { id: 3, name: "37signals", division: "First", accounting_date: '2005-01-01' }
   #   ).first
   #
   # Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
   # operator. For instance:
   #
-  #   Student.where(:first_name => "Harvey", :status => 1)
+  #   Student.where(first_name: "Harvey", status: 1)
   #   Student.where(params[:student])
   #
   # A range may be used in the hash to use the SQL BETWEEN operator:
   #
-  #   Student.where(:grade => 9..12)
+  #   Student.where(grade: 9..12)
   #
   # An array may be used in the hash to use the SQL IN operator:
   #
-  #   Student.where(:grade => [9,11,12])
+  #   Student.where(grade: [9,11,12])
   #
   # When joining tables, nested hashes or keys written in the form 'table_name.column_name'
   # can be used to qualify the table name of a particular condition. For instance:
   #
-  #   Student.joins(:schools).where(:schools => { :category => 'public' })
+  #   Student.joins(:schools).where(schools: { category: 'public' })
   #   Student.joins(:schools).where('schools.category' => 'public' )
   #
   # == Overwriting default accessors
@@ -141,10 +141,10 @@ module ActiveRecord #:nodoc:
   # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
   # to determine whether the user has a name:
   #
-  #   user = User.new(:name => "David")
+  #   user = User.new(name: "David")
   #   user.name? # => true
   #
-  #   anonymous = User.new(:name => "")
+  #   anonymous = User.new(name: "")
   #   anonymous.name? # => false
   #
   # == Accessing attributes before they have been typecasted
@@ -165,8 +165,8 @@ module ActiveRecord #:nodoc:
   # to <tt>find_by_</tt>, <tt>find_last_by_</tt>, or <tt>find_all_by_</tt> and thus produces finders
   # like <tt>Person.find_by_user_name</tt>, <tt>Person.find_all_by_last_name</tt>, and
   # <tt>Payment.find_by_transaction_id</tt>. Instead of writing
-  # <tt>Person.where(:user_name => user_name).first</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
-  # And instead of writing <tt>Person.where(:last_name => last_name).all</tt>, you just do
+  # <tt>Person.where(user_name: user_name).first</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
+  # And instead of writing <tt>Person.where(last_name: last_name).all</tt>, you just do
   # <tt>Person.find_all_by_last_name(last_name)</tt>.
   #
   # It's possible to add an exclamation point (!) on the end of the dynamic finders to get them to raise an
@@ -175,7 +175,7 @@ module ActiveRecord #:nodoc:
   #
   # It's also possible to use multiple attributes in the same find by separating them with "_and_".
   #
-  #  Person.where(:user_name => user_name, :password => password).first
+  #  Person.where(user_name: user_name, password: password).first
   #  Person.find_by_user_name_and_password(user_name, password) # with dynamic finder
   #
   # It's even possible to call these dynamic finder methods on relations and named scopes.
@@ -189,13 +189,13 @@ module ActiveRecord #:nodoc:
   # unless they are given in a block.
   #
   #   # No 'Summer' tag exists
-  #   Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
+  #   Tag.find_or_create_by_name("Summer") # equal to Tag.create(name: "Summer")
   #
   #   # Now the 'Summer' tag does exist
   #   Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
   #
   #   # Now 'Bob' exist and is an 'admin'
-  #   User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true }
+  #   User.find_or_create_by_name('Bob', age: 40) { |u| u.admin = true }
   #
   # Adding an exclamation point (!) on to the end of <tt>find_or_create_by_</tt> will
   # raise an <tt>ActiveRecord::RecordInvalid</tt> error if the new record is invalid.
@@ -210,7 +210,7 @@ module ActiveRecord #:nodoc:
   # To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of
   # a list of parameters.
   #
-  #   Tag.find_or_create_by_name(:name => "rails", :creator => current_user)
+  #   Tag.find_or_create_by_name(name: "rails", creator: current_user)
   #
   # That will either find an existing tag named "rails", or create a new one while setting the
   # user that created it.
@@ -232,7 +232,7 @@ module ActiveRecord #:nodoc:
   #     serialize :preferences
   #   end
   #
-  #   user = User.create(:preferences => { "background" => "black", "display" => large })
+  #   user = User.create(preferences: { "background" => "black", "display" => large })
   #   User.find(user.id).preferences # => { "background" => "black", "display" => large }
   #
   # You can also specify a class option as the second parameter that'll raise an exception
@@ -242,7 +242,7 @@ module ActiveRecord #:nodoc:
   #     serialize :preferences, Hash
   #   end
   #
-  #   user = User.create(:preferences => %w( one two three ))
+  #   user = User.create(preferences: %w( one two three ))
   #   User.find(user.id).preferences    # raises SerializationTypeMismatch
   #
   # When you specify a class option, the default value for that attribute will be a new
@@ -267,9 +267,9 @@ module ActiveRecord #:nodoc:
   #   class Client < Company; end
   #   class PriorityClient < Client; end
   #
-  # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in
+  # When you do <tt>Firm.create(name: "37signals")</tt>, this record will be saved in
   # the companies table with type = "Firm". You can then fetch this row again using
-  # <tt>Company.where(:name => '37signals').first</tt> and it will return a Firm object.
+  # <tt>Company.where(name: '37signals').first</tt> and it will return a Firm object.
   #
   # If you don't have a type column defined in your table, single-table inheritance won't
   # be triggered. In that case, it'll work just like normal subclasses with no special magic
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index 725bfffef2..1c9c627090 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -35,7 +35,7 @@ module ActiveRecord
   #   class CreditCard < ActiveRecord::Base
   #     # Strip everything but digits, so the user can specify "555 234 34" or
   #     # "5552-3434" and both will mean "55523434"
-  #     before_validation(:on => :create) do
+  #     before_validation(on: :create) do
   #       self.number = number.gsub(/[^0-9]/, "") if attribute_present?("number")
   #     end
   #   end
diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb
index 8ce7a7a463..d6d998c7be 100644
--- a/activerecord/lib/active_record/connection_handling.rb
+++ b/activerecord/lib/active_record/connection_handling.rb
@@ -5,18 +5,18 @@ module ActiveRecord
     # example for regular databases (MySQL, Postgresql, etc):
     #
     #   ActiveRecord::Base.establish_connection(
-    #     :adapter  => "mysql",
-    #     :host     => "localhost",
-    #     :username => "myuser",
-    #     :password => "mypass",
-    #     :database => "somedatabase"
+    #     adapter:  "mysql",
+    #     host:     "localhost",
+    #     username: "myuser",
+    #     password: "mypass",
+    #     database: "somedatabase"
     #   )
     #
     # Example for SQLite database:
     #
     #   ActiveRecord::Base.establish_connection(
-    #     :adapter => "sqlite",
-    #     :database  => "path/to/dbfile"
+    #     adapter: "sqlite",
+    #     database:  "path/to/dbfile"
     #   )
     #
     # Also accepts keys as strings (for parsing from YAML for example):
@@ -64,7 +64,7 @@ module ActiveRecord
     # Returns the configuration of the associated connection as a hash:
     #
     #  ActiveRecord::Base.connection_config
-    #  # => {:pool=>5, :timeout=>5000, :database=>"db/development.sqlite3", :adapter=>"sqlite3"}
+    #  # => {pool: 5, timeout: 5000, database: "db/development.sqlite3", adapter: "sqlite3"}
     #
     # Please use only for reading.
     def connection_config
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 98032db2ef..fdc3d2f6db 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -157,7 +157,7 @@ module ActiveRecord
     #
     # ==== Example:
     #   # Instantiates a single new object
-    #   User.new(:first_name => 'Jamie')
+    #   User.new(first_name: 'Jamie')
     def initialize(attributes = nil)
       defaults = self.class.column_defaults.dup
       defaults.each { |k, v| defaults[k] = v.dup if v.duplicable? }
-- 
cgit v1.2.3


From 890da5149df19c54124929ff8b533014b6b46e69 Mon Sep 17 00:00:00 2001
From: AvnerCohen <israbirding@gmail.com>
Date: Sat, 10 Nov 2012 17:16:21 +0200
Subject: 1.9 Syntax related changes

---
 activerecord/lib/active_record/counter_cache.rb    |  4 +-
 activerecord/lib/active_record/errors.rb           |  2 +-
 activerecord/lib/active_record/fixtures.rb         |  4 +-
 .../lib/active_record/locking/pessimistic.rb       |  6 +-
 activerecord/lib/active_record/model_schema.rb     |  2 +-
 .../lib/active_record/nested_attributes.rb         | 70 +++++++++++-----------
 activerecord/lib/active_record/relation.rb         |  2 +-
 .../lib/active_record/relation/calculations.rb     |  2 +-
 .../lib/active_record/relation/finder_methods.rb   |  2 +-
 .../active_record/relation/predicate_builder.rb    |  4 +-
 .../lib/active_record/relation/query_methods.rb    | 18 +++---
 .../lib/active_record/relation/spawn_methods.rb    |  4 +-
 activerecord/lib/active_record/sanitization.rb     | 24 ++++----
 .../active_record/serializers/xml_serializer.rb    | 14 ++---
 activerecord/lib/active_record/transactions.rb     | 28 ++++-----
 15 files changed, 93 insertions(+), 93 deletions(-)

(limited to 'activerecord')

diff --git a/activerecord/lib/active_record/counter_cache.rb b/activerecord/lib/active_record/counter_cache.rb
index 57838ff984..c53b7b3e78 100644
--- a/activerecord/lib/active_record/counter_cache.rb
+++ b/activerecord/lib/active_record/counter_cache.rb
@@ -56,7 +56,7 @@ module ActiveRecord
       #
       #   # For the Post with id of 5, decrement the comment_count by 1, and
       #   # increment the action_count by 1
-      #   Post.update_counters 5, :comment_count => -1, :action_count => 1
+      #   Post.update_counters 5, comment_count: -1, action_count: 1
       #   # Executes the following SQL:
       #   # UPDATE posts
       #   #    SET comment_count = COALESCE(comment_count, 0) - 1,
@@ -64,7 +64,7 @@ module ActiveRecord
       #   #  WHERE id = 5
       #
       #   # For the Posts with id of 10 and 15, increment the comment_count by 1
-      #   Post.update_counters [10, 15], :comment_count => 1
+      #   Post.update_counters [10, 15], comment_count: 1
       #   # Executes the following SQL:
       #   # UPDATE posts
       #   #    SET comment_count = COALESCE(comment_count, 0) + 1
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb
index 04c0fbfe70..c615d59725 100644
--- a/activerecord/lib/active_record/errors.rb
+++ b/activerecord/lib/active_record/errors.rb
@@ -22,7 +22,7 @@ module ActiveRecord
   #   end
   #
   #   # Comments are not patches, this assignment raises AssociationTypeMismatch.
-  #   @ticket.patches << Comment.new(:content => "Please attach tests to your patch.")
+  #   @ticket.patches << Comment.new(content: "Please attach tests to your patch.")
   class AssociationTypeMismatch < ActiveRecordError
   end
 
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 29a99a5336..c1c05eb8fb 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -250,7 +250,7 @@ module ActiveRecord
   #
   #   ### in fruit.rb
   #
-  #   belongs_to :eater, :polymorphic => true
+  #   belongs_to :eater, polymorphic: true
   #
   #   ### in fruits.yml
   #
@@ -730,7 +730,7 @@ module ActiveRecord
       #
       # Examples:
       #
-      #   set_fixture_class :some_fixture        => SomeModel,
+      #   set_fixture_class some_fixture:        SomeModel,
       #                     'namespaced/fixture' => Another::Model
       #
       # The keys must be the fixture names, that coincide with the short paths to the fixture files.
diff --git a/activerecord/lib/active_record/locking/pessimistic.rb b/activerecord/lib/active_record/locking/pessimistic.rb
index 58af92f0b1..b4bb95a392 100644
--- a/activerecord/lib/active_record/locking/pessimistic.rb
+++ b/activerecord/lib/active_record/locking/pessimistic.rb
@@ -3,12 +3,12 @@ module ActiveRecord
     # Locking::Pessimistic provides support for row-level locking using
     # SELECT ... FOR UPDATE and other lock types.
     #
-    # Pass <tt>:lock => true</tt> to <tt>ActiveRecord::Base.find</tt> to obtain an exclusive
+    # Pass <tt>lock: true</tt> to <tt>ActiveRecord::Base.find</tt> to obtain an exclusive
     # lock on the selected rows:
     #   # select * from accounts where id=1 for update
-    #   Account.find(1, :lock => true)
+    #   Account.find(1, lock: true)
     #
-    # Pass <tt>:lock => 'some locking clause'</tt> to give a database-specific locking clause
+    # Pass <tt>lock: 'some locking clause'</tt> to give a database-specific locking clause
     # of your own such as 'LOCK IN SHARE MODE' or 'FOR UPDATE NOWAIT'. Example:
     #
     #   Account.transaction do
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 1b95b72c8a..628ab0f566 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -285,7 +285,7 @@ module ActiveRecord
       #
       #      JobLevel.reset_column_information
       #      %w{assistant executive manager director}.each do |type|
-      #        JobLevel.create(:name => type)
+      #        JobLevel.create(name: type)
       #      end
       #    end
       #
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index aba56c2861..4c9bd76d7c 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -50,14 +50,14 @@ module ActiveRecord
     # Enabling nested attributes on a one-to-one association allows you to
     # create the member and avatar in one go:
     #
-    #   params = { :member => { :name => 'Jack', :avatar_attributes => { :icon => 'smiling' } } }
+    #   params = { member: { name: 'Jack', avatar_attributes: { icon: 'smiling' } } }
     #   member = Member.create(params[:member])
     #   member.avatar.id # => 2
     #   member.avatar.icon # => 'smiling'
     #
     # It also allows you to update the avatar through the member:
     #
-    #   params = { :member => { :avatar_attributes => { :id => '2', :icon => 'sad' } } }
+    #   params = { member: { avatar_attributes: { id: '2', icon: 'sad' } } }
     #   member.update_attributes params[:member]
     #   member.avatar.icon # => 'sad'
     #
@@ -68,13 +68,13 @@ module ActiveRecord
     #
     #   class Member < ActiveRecord::Base
     #     has_one :avatar
-    #     accepts_nested_attributes_for :avatar, :allow_destroy => true
+    #     accepts_nested_attributes_for :avatar, allow_destroy: true
     #   end
     #
     # Now, when you add the <tt>_destroy</tt> key to the attributes hash, with a
     # value that evaluates to +true+, you will destroy the associated model:
     #
-    #   member.avatar_attributes = { :id => '2', :_destroy => '1' }
+    #   member.avatar_attributes = { id: '2', _destroy: '1' }
     #   member.avatar.marked_for_destruction? # => true
     #   member.save
     #   member.reload.avatar # => nil
@@ -97,11 +97,11 @@ module ActiveRecord
     # be instantiated, unless the hash also contains a <tt>_destroy</tt> key
     # that evaluates to +true+.
     #
-    #   params = { :member => {
-    #     :name => 'joe', :posts_attributes => [
-    #       { :title => 'Kari, the awesome Ruby documentation browser!' },
-    #       { :title => 'The egalitarian assumption of the modern citizen' },
-    #       { :title => '', :_destroy => '1' } # this will be ignored
+    #   params = { member: {
+    #     name: 'joe', posts_attributes: [
+    #       { title: 'Kari, the awesome Ruby documentation browser!' },
+    #       { title: 'The egalitarian assumption of the modern citizen' },
+    #       { title: '', _destroy: '1' } # this will be ignored
     #     ]
     #   }}
     #
@@ -116,14 +116,14 @@ module ActiveRecord
     #
     #    class Member < ActiveRecord::Base
     #      has_many :posts
-    #      accepts_nested_attributes_for :posts, :reject_if => proc { |attributes| attributes['title'].blank? }
+    #      accepts_nested_attributes_for :posts, reject_if: proc { |attributes| attributes['title'].blank? }
     #    end
     #
-    #   params = { :member => {
-    #     :name => 'joe', :posts_attributes => [
-    #       { :title => 'Kari, the awesome Ruby documentation browser!' },
-    #       { :title => 'The egalitarian assumption of the modern citizen' },
-    #       { :title => '' } # this will be ignored because of the :reject_if proc
+    #   params = { member: {
+    #     name: 'joe', posts_attributes: [
+    #       { title: 'Kari, the awesome Ruby documentation browser!' },
+    #       { title: 'The egalitarian assumption of the modern citizen' },
+    #       { title: '' } # this will be ignored because of the :reject_if proc
     #     ]
     #   }}
     #
@@ -136,12 +136,12 @@ module ActiveRecord
     #
     #    class Member < ActiveRecord::Base
     #      has_many :posts
-    #      accepts_nested_attributes_for :posts, :reject_if => :new_record?
+    #      accepts_nested_attributes_for :posts, reject_if: :new_record?
     #    end
     #
     #    class Member < ActiveRecord::Base
     #      has_many :posts
-    #      accepts_nested_attributes_for :posts, :reject_if => :reject_posts
+    #      accepts_nested_attributes_for :posts, reject_if: :reject_posts
     #
     #      def reject_posts(attributed)
     #        attributed['title'].blank?
@@ -152,10 +152,10 @@ module ActiveRecord
     # associated record, the matching record will be modified:
     #
     #   member.attributes = {
-    #     :name => 'Joe',
-    #     :posts_attributes => [
-    #       { :id => 1, :title => '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' },
-    #       { :id => 2, :title => '[UPDATED] other post' }
+    #     name: 'Joe',
+    #     posts_attributes: [
+    #       { id: 1, title: '[UPDATED] An, as of yet, undisclosed awesome Ruby documentation browser!' },
+    #       { id: 2, title: '[UPDATED] other post' }
     #     ]
     #   }
     #
@@ -170,11 +170,11 @@ module ActiveRecord
     #
     #   class Member < ActiveRecord::Base
     #     has_many :posts
-    #     accepts_nested_attributes_for :posts, :allow_destroy => true
+    #     accepts_nested_attributes_for :posts, allow_destroy: true
     #   end
     #
-    #   params = { :member => {
-    #     :posts_attributes => [{ :id => '2', :_destroy => '1' }]
+    #   params = { member: {
+    #     posts_attributes: [{ id: '2', _destroy: '1' }]
     #   }}
     #
     #   member.attributes = params[:member]
@@ -197,12 +197,12 @@ module ActiveRecord
     # <tt>inverse_of</tt> as this example illustrates:
     #
     #   class Member < ActiveRecord::Base
-    #     has_many :posts, :inverse_of => :member
+    #     has_many :posts, inverse_of: :member
     #     accepts_nested_attributes_for :posts
     #   end
     #
     #   class Post < ActiveRecord::Base
-    #     belongs_to :member, :inverse_of => :posts
+    #     belongs_to :member, inverse_of: :posts
     #     validates_presence_of :member
     #   end
     module ClassMethods
@@ -248,11 +248,11 @@ module ActiveRecord
       #
       # Examples:
       #   # creates avatar_attributes=
-      #   accepts_nested_attributes_for :avatar, :reject_if => proc { |attributes| attributes['name'].blank? }
+      #   accepts_nested_attributes_for :avatar, reject_if: proc { |attributes| attributes['name'].blank? }
       #   # creates avatar_attributes=
-      #   accepts_nested_attributes_for :avatar, :reject_if => :all_blank
+      #   accepts_nested_attributes_for :avatar, reject_if: :all_blank
       #   # creates avatar_attributes= and posts_attributes=
-      #   accepts_nested_attributes_for :avatar, :posts, :allow_destroy => true
+      #   accepts_nested_attributes_for :avatar, :posts, allow_destroy: true
       def accepts_nested_attributes_for(*attr_names)
         options = { :allow_destroy => false, :update_only => false }
         options.update(attr_names.extract_options!)
@@ -348,9 +348,9 @@ module ActiveRecord
     # For example:
     #
     #   assign_nested_attributes_for_collection_association(:people, {
-    #     '1' => { :id => '1', :name => 'Peter' },
-    #     '2' => { :name => 'John' },
-    #     '3' => { :id => '2', :_destroy => true }
+    #     '1' => { id: '1', name: 'Peter' },
+    #     '2' => { name: 'John' },
+    #     '3' => { id: '2', _destroy: true }
     #   })
     #
     # Will update the name of the Person with ID 1, build a new associated
@@ -360,9 +360,9 @@ module ActiveRecord
     # Also accepts an Array of attribute hashes:
     #
     #   assign_nested_attributes_for_collection_association(:people, [
-    #     { :id => '1', :name => 'Peter' },
-    #     { :name => 'John' },
-    #     { :id => '2', :_destroy => true }
+    #     { id: '1', name: 'Peter' },
+    #     { name: 'John' },
+    #     { id: '2', _destroy: true }
     #   ])
     def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
       options = self.nested_attributes_options[association_name]
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index cb9cc5a9df..3ee55c580e 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -486,7 +486,7 @@ module ActiveRecord
     # Returns a hash of where conditions
     #
     #   Users.where(name: 'Oscar').where_values_hash
-    #   # => {:name=>"oscar"}
+    #   # => {name: "oscar"}
     def where_values_hash
       equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
         node.left.relation.name == table_name
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index a7d2f4bd24..6120ffd4c3 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -145,7 +145,7 @@ module ActiveRecord
     #   # SELECT DISTINCT role FROM people
     #   # => ['admin', 'member', 'guest']
     #
-    #   Person.where(:age => 21).limit(5).pluck(:id)
+    #   Person.where(age: 21).limit(5).pluck(:id)
     #   # SELECT people.id FROM people WHERE people.age = 21 LIMIT 5
     #   # => [2, 3]
     #
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 99c2f45bc8..d8131680a3 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -78,7 +78,7 @@ module ActiveRecord
     #
     #   Person.first # returns the first object fetched by SELECT * FROM people
     #   Person.where(["user_name = ?", user_name]).first
-    #   Person.where(["user_name = :u", { :u => user_name }]).first
+    #   Person.where(["user_name = :u", { u: user_name }]).first
     #   Person.order("created_on DESC").offset(5).first
     #   Person.first(3) # returns the first three objects fetched by SELECT * FROM people LIMIT 3
     def first(limit = nil)
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index bd7aeb0c4e..83074e72c1 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -36,10 +36,10 @@ module ActiveRecord
       queries = []
 
       # Find the foreign key when using queries such as:
-      # Post.where(:author => author)
+      # Post.where(author: author)
       #
       # For polymorphic relationships, find the foreign key and type:
-      # PriceEstimate.where(:estimate_of => treasure)
+      # PriceEstimate.where(estimate_of: treasure)
       if klass && value.class < Base && reflection = klass.reflect_on_association(column.to_sym)
         if reflection.polymorphic?
           queries << build(table[reflection.foreign_type], value.class.base_class)
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 4fdc296c7e..81ad0cc768 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -357,17 +357,17 @@ module ActiveRecord
     #    author = Author.find(1)
     #
     #    # The following queries will be equivalent:
-    #    Post.where(:author => author)
-    #    Post.where(:author_id => author)
+    #    Post.where(author: author)
+    #    Post.where(author_id: author)
     #
     # This also works with polymorphic belongs_to relationships:
     #
-    #    treasure = Treasure.create(:name => 'gold coins')
-    #    treasure.price_estimates << PriceEstimate.create(:price => 125)
+    #    treasure = Treasure.create(name: 'gold coins')
+    #    treasure.price_estimates << PriceEstimate.create(price: 125)
     #
     #    # The following queries will be equivalent:
-    #    PriceEstimate.where(:estimate_of => treasure)
-    #    PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure)
+    #    PriceEstimate.where(estimate_of: treasure)
+    #    PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: treasure)
     #
     # === Joins
     #
@@ -379,7 +379,7 @@ module ActiveRecord
     # For hash conditions, you can either use the table name in the key, or use a sub-hash.
     #
     #    User.joins(:posts).where({ "posts.published" => true })
-    #    User.joins(:posts).where({ :posts => { :published => true } })
+    #    User.joins(:posts).where({ posts: { published: true } })
     #
     # === empty condition
     #
@@ -478,13 +478,13 @@ module ActiveRecord
     #
     # For example:
     #
-    #   @posts = current_user.visible_posts.where(:name => params[:name])
+    #   @posts = current_user.visible_posts.where(name: params[:name])
     #   # => the visible_posts method is expected to return a chainable Relation
     #
     #   def visible_posts
     #     case role
     #     when 'Country Manager'
-    #       Post.where(:country => country)
+    #       Post.where(country: country)
     #     when 'Reviewer'
     #       Post.published
     #     when 'Bad User'
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 5394c1b28b..62dda542ab 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -15,11 +15,11 @@ module ActiveRecord
     #
     # ==== Examples
     #
-    #   Post.where(:published => true).joins(:comments).merge( Comment.where(:spam => false) )
+    #   Post.where(published: true).joins(:comments).merge( Comment.where(spam: false) )
     #   # Performs a single join query with both where conditions.
     #
     #   recent_posts = Post.order('created_at DESC').first(5)
-    #   Post.where(:published => true).merge(recent_posts)
+    #   Post.where(published: true).merge(recent_posts)
     #   # Returns the intersection of all published posts with the 5 most recently created posts.
     #   # (This is just an example. You'd probably want to do this with a single query!)
     #
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index f3e47a958e..2dad1dc177 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -17,7 +17,7 @@ module ActiveRecord
       # Accepts an array, hash, or string of SQL conditions and sanitizes
       # them into a valid SQL fragment for a WHERE clause.
       #   ["name='%s' and group_id='%s'", "foo'bar", 4]  returns  "name='foo''bar' and group_id='4'"
-      #   { :name => "foo'bar", :group_id => 4 }  returns "name='foo''bar' and group_id='4'"
+      #   { name: "foo'bar", group_id: 4 }  returns "name='foo''bar' and group_id='4'"
       #   "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
       def sanitize_sql_for_conditions(condition, table_name = self.table_name)
         return nil if condition.blank?
@@ -32,7 +32,7 @@ module ActiveRecord
 
       # Accepts an array, hash, or string of SQL conditions and sanitizes
       # them into a valid SQL fragment for a SET clause.
-      #   { :name => nil, :group_id => 4 }  returns "name = NULL , group_id='4'"
+      #   { name: nil, group_id: 4 }  returns "name = NULL , group_id='4'"
       def sanitize_sql_for_assignment(assignments)
         case assignments
         when Array; sanitize_sql_array(assignments)
@@ -46,12 +46,12 @@ module ActiveRecord
       # aggregate attribute values.
       # Given:
       #     class Person < ActiveRecord::Base
-      #       composed_of :address, :class_name => "Address",
-      #         :mapping => [%w(address_street street), %w(address_city city)]
+      #       composed_of :address, class_name: "Address",
+      #         mapping: [%w(address_street street), %w(address_city city)]
       #     end
       # Then:
-      #     { :address => Address.new("813 abc st.", "chicago") }
-      #       # => { :address_street => "813 abc st.", :address_city => "chicago" }
+      #     { address: Address.new("813 abc st.", "chicago") }
+      #       # => { address_street: "813 abc st.", address_city: "chicago" }
       def expand_hash_conditions_for_aggregates(attrs)
         expanded_attrs = {}
         attrs.each do |attr, value|
@@ -72,18 +72,18 @@ module ActiveRecord
       end
 
       # Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
-      #   { :name => "foo'bar", :group_id => 4 }
+      #   { name: "foo'bar", group_id: 4 }
       #     # => "name='foo''bar' and group_id= 4"
-      #   { :status => nil, :group_id => [1,2,3] }
+      #   { status: nil, group_id: [1,2,3] }
       #     # => "status IS NULL and group_id IN (1,2,3)"
-      #   { :age => 13..18 }
+      #   { age: 13..18 }
       #     # => "age BETWEEN 13 AND 18"
       #   { 'other_records.id' => 7 }
       #     # => "`other_records`.`id` = 7"
-      #   { :other_records => { :id => 7 } }
+      #   { other_records: { id: 7 } }
       #     # => "`other_records`.`id` = 7"
       # And for value objects on a composed_of relationship:
-      #   { :address => Address.new("123 abc st.", "chicago") }
+      #   { address: Address.new("123 abc st.", "chicago") }
       #     # => "address_street='123 abc st.' and address_city='chicago'"
       def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name)
         attrs = expand_hash_conditions_for_aggregates(attrs)
@@ -96,7 +96,7 @@ module ActiveRecord
       alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
 
       # Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause.
-      #   { :status => nil, :group_id => 1 }
+      #   { status: nil, group_id: 1 }
       #     # => "status = NULL , group_id = 1"
       def sanitize_sql_hash_for_assignment(attrs)
         attrs.map do |attr, value|
diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb
index 834d01a1e8..1a766093d0 100644
--- a/activerecord/lib/active_record/serializers/xml_serializer.rb
+++ b/activerecord/lib/active_record/serializers/xml_serializer.rb
@@ -36,7 +36,7 @@ module ActiveRecord #:nodoc:
     #
     # For instance:
     #
-    #   topic.to_xml(:skip_instruct => true, :except => [ :id, :bonus_time, :written_on, :replies_count ])
+    #   topic.to_xml(skip_instruct: true, except: [ :id, :bonus_time, :written_on, :replies_count ])
     #
     #   <topic>
     #     <title>The First Topic</title>
@@ -50,7 +50,7 @@ module ActiveRecord #:nodoc:
     #
     # To include first level associations use <tt>:include</tt>:
     #
-    #   firm.to_xml :include => [ :account, :clients ]
+    #   firm.to_xml include: [ :account, :clients ]
     #
     #   <?xml version="1.0" encoding="UTF-8"?>
     #   <firm>
@@ -81,7 +81,7 @@ module ActiveRecord #:nodoc:
     # associated with models.
     #
     #   proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) }
-    #   firm.to_xml :procs => [ proc ]
+    #   firm.to_xml procs: [ proc ]
     #
     #   <firm>
     #     # ... normal attributes as shown above ...
@@ -90,7 +90,7 @@ module ActiveRecord #:nodoc:
     #
     # To include deeper levels of associations pass a hash like this:
     #
-    #   firm.to_xml :include => {:account => {}, :clients => {:include => :address}}
+    #   firm.to_xml include: {account: {}, clients: {include: :address}}
     #   <?xml version="1.0" encoding="UTF-8"?>
     #   <firm>
     #     <id type="integer">1</id>
@@ -120,7 +120,7 @@ module ActiveRecord #:nodoc:
     #
     # To include any methods on the model being called use <tt>:methods</tt>:
     #
-    #   firm.to_xml :methods => [ :calculated_earnings, :real_earnings ]
+    #   firm.to_xml methods: [ :calculated_earnings, :real_earnings ]
     #
     #   <firm>
     #     # ... normal attributes as shown above ...
@@ -132,7 +132,7 @@ module ActiveRecord #:nodoc:
     # modified version of the options hash that was given to +to_xml+:
     #
     #   proc = Proc.new { |options| options[:builder].tag!('abc', 'def') }
-    #   firm.to_xml :procs => [ proc ]
+    #   firm.to_xml procs: [ proc ]
     #
     #   <firm>
     #     # ... normal attributes as shown above ...
@@ -164,7 +164,7 @@ module ActiveRecord #:nodoc:
     #     def to_xml(options = {})
     #       require 'builder'
     #       options[:indent] ||= 2
-    #       xml = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
+    #       xml = options[:builder] ||= ::Builder::XmlMarkup.new(indent: options[:indent])
     #       xml.instruct! unless options[:skip_instruct]
     #       xml.level_one do
     #         xml.tag!(:second_level, 'content')
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index f91abfbd19..ce6998530f 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -108,10 +108,10 @@ module ActiveRecord
     #
     #   # Suppose that we have a Number model with a unique column called 'i'.
     #   Number.transaction do
-    #     Number.create(:i => 0)
+    #     Number.create(i: 0)
     #     begin
     #       # This will raise a unique constraint error...
-    #       Number.create(:i => 0)
+    #       Number.create(i: 0)
     #     rescue ActiveRecord::StatementInvalid
     #       # ...which we ignore.
     #     end
@@ -119,7 +119,7 @@ module ActiveRecord
     #     # On PostgreSQL, the transaction is now unusable. The following
     #     # statement will cause a PostgreSQL error, even though the unique
     #     # constraint is no longer violated:
-    #     Number.create(:i => 1)
+    #     Number.create(i: 1)
     #     # => "PGError: ERROR:  current transaction is aborted, commands
     #     #     ignored until end of transaction block"
     #   end
@@ -134,9 +134,9 @@ module ActiveRecord
     # transaction. For example, the following behavior may be surprising:
     #
     #   User.transaction do
-    #     User.create(:username => 'Kotori')
+    #     User.create(username: 'Kotori')
     #     User.transaction do
-    #       User.create(:username => 'Nemu')
+    #       User.create(username: 'Nemu')
     #       raise ActiveRecord::Rollback
     #     end
     #   end
@@ -147,14 +147,14 @@ module ActiveRecord
     # real transaction is committed.
     #
     # In order to get a ROLLBACK for the nested transaction you may ask for a real
-    # sub-transaction by passing <tt>:requires_new => true</tt>. If anything goes wrong,
+    # sub-transaction by passing <tt>requires_new: true</tt>. If anything goes wrong,
     # the database rolls back to the beginning of the sub-transaction without rolling
     # back the parent transaction. If we add it to the previous example:
     #
     #   User.transaction do
-    #     User.create(:username => 'Kotori')
-    #     User.transaction(:requires_new => true) do
-    #       User.create(:username => 'Nemu')
+    #     User.create(username: 'Kotori')
+    #     User.transaction(requires_new: true) do
+    #       User.create(username: 'Nemu')
     #       raise ActiveRecord::Rollback
     #     end
     #   end
@@ -194,7 +194,7 @@ module ActiveRecord
     # automatically released. The following example demonstrates the problem:
     #
     #   Model.connection.transaction do                           # BEGIN
-    #     Model.connection.transaction(:requires_new => true) do  # CREATE SAVEPOINT active_record_1
+    #     Model.connection.transaction(requires_new: true) do  # CREATE SAVEPOINT active_record_1
     #       Model.connection.create_table(...)                    # active_record_1 now automatically released
     #     end                                                     # RELEASE savepoint active_record_1
     #                                                             # ^^^^ BOOM! database error!
@@ -213,13 +213,13 @@ module ActiveRecord
       # You can specify that the callback should only be fired by a certain action with
       # the +:on+ option:
       #
-      #   after_commit :do_foo, :on => :create
-      #   after_commit :do_bar, :on => :update
-      #   after_commit :do_baz, :on => :destroy
+      #   after_commit :do_foo, on: :create
+      #   after_commit :do_bar, on: :update
+      #   after_commit :do_baz, on: :destroy
       #
       # Also, to have the callback fired on create and update, but not on destroy:
       #
-      #   after_commit :do_zoo, :if => :persisted?
+      #   after_commit :do_zoo, if: :persisted?
       #
       # Note that transactional fixtures do not play well with this feature. Please
       # use the +test_after_commit+ gem to have these hooks fired in tests.
-- 
cgit v1.2.3