From 97350762da7c723eb49e30f827ee2e4eb5997fd8 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 11:31:22 -0700 Subject: Add documentation for create_with --- .../lib/active_record/relation/query_methods.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 1271b74ead..b132e3e42e 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -405,7 +405,7 @@ module ActiveRecord end # Specifies locking settings (default to +true+). For more information - # on locking, please see +ActiveRecord::Locking+. + # on locking, please see +ActiveRecord::Lockin+g. def lock(locks = true) spawn.lock!(locks) end @@ -469,10 +469,28 @@ module ActiveRecord self end + # Sets attributes to be used when creating new records from a + # relation object. + # + # users = User.where(name: 'Oscar') + # users.new.name # => 'Oscar' + # + # users = users.create_with(name: 'DHH') + # users.new.name # => 'DHH' + # + # You can pass +nil+ to +create_with+ to reset attributes: + # + # users = users.create_with(nil) + # users.new.name # => 'Oscar' def create_with(value) spawn.create_with!(value) end + # Like #create_with but modifies the relation in place. Raises + # +ImmutableRelation+ if the relation has already been loaded. + # + # users = User.scoped.create_with!(name: 'Oscar') + # users.name # => 'Oscar' def create_with!(value) self.create_with_value = value ? create_with_value.merge(value) : {} self -- cgit v1.2.3 From c0e186c1555f43f53df70c1736de7047d5f4e678 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 11:55:46 -0700 Subject: Add documentation for arel and build_arel --- activerecord/lib/active_record/relation/query_methods.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index b132e3e42e..5278e740da 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -602,10 +602,12 @@ module ActiveRecord self end + # Returns the Arel object associated with the relation. def arel @arel ||= with_default_scope.build_arel end + # Like #arel, but ignores the default scope of the model. def build_arel arel = Arel::SelectManager.new(table.engine, table) -- cgit v1.2.3 From 37afdef536ba02c73e9861df4b25460f3a4b160e Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 12:02:45 -0700 Subject: Add nodoc to create_with_value Reason: all *_value methods are defined dynamically and so don't appear in the documentation. --- activerecord/lib/active_record/relation/query_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 5278e740da..136e5778f6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -35,7 +35,7 @@ module ActiveRecord CODE end - def create_with_value + def create_with_value # :nodoc: @values[:create_with] || {} end -- cgit v1.2.3 From 993ef9ed59e651aac0160a72ff032ce6faacf427 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 12:28:53 -0700 Subject: Add documentation for query_methods bang methods --- .../lib/active_record/relation/query_methods.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 136e5778f6..c057a684e6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -67,6 +67,7 @@ module ActiveRecord args.empty? ? self : spawn.includes!(*args) end + # Like #includes, but modifies the relation in place. def includes!(*args) args.reject! {|a| a.blank? } @@ -84,6 +85,8 @@ module ActiveRecord args.blank? ? self : spawn.eager_load!(*args) end + # Like #eager_load, but modifies relation in place. + # object. def eager_load!(*args) self.eager_load_values += args self @@ -97,6 +100,7 @@ module ActiveRecord args.blank? ? self : spawn.preload!(*args) end + # Like #preload, but modifies relation in place. def preload!(*args) self.preload_values += args self @@ -114,6 +118,7 @@ module ActiveRecord args.blank? ? self : spawn.references!(*args) end + # Like #references, but modifies relation in place. def references!(*args) args.flatten! @@ -158,6 +163,7 @@ module ActiveRecord end end + # Like #select, but modifies relation in place. def select!(value) self.select_values += Array.wrap(value) self @@ -179,6 +185,7 @@ module ActiveRecord args.blank? ? self : spawn.group!(*args) end + # Like #group, but modifies relation in place. def group!(*args) args.flatten! @@ -200,6 +207,7 @@ module ActiveRecord args.blank? ? self : spawn.order!(*args) end + # Like #order, but modifies relation in place. def order!(*args) args.flatten! @@ -224,6 +232,7 @@ module ActiveRecord args.blank? ? self : spawn.reorder!(*args) end + # Like #reorder, but modifies relation in place. def reorder!(*args) args.flatten! @@ -240,6 +249,7 @@ module ActiveRecord args.compact.blank? ? self : spawn.joins!(*args) end + # Like #joins, but modifies relation in place. def joins!(*args) args.flatten! @@ -367,6 +377,7 @@ module ActiveRecord opts.blank? ? self : spawn.having!(opts, *rest) end + # Like #having, but modifies relation in place. def having!(opts, *rest) references!(PredicateBuilder.references(opts)) if Hash === opts @@ -383,6 +394,7 @@ module ActiveRecord spawn.limit!(value) end + # Like #limit, but modifies relation in place. def limit!(value) self.limit_value = value self @@ -399,17 +411,19 @@ module ActiveRecord spawn.offset!(value) end + # Like #offset, but modifies relation in place. def offset!(value) self.offset_value = value self end # Specifies locking settings (default to +true+). For more information - # on locking, please see +ActiveRecord::Lockin+g. + # on locking, please see +ActiveRecord::Locking+. def lock(locks = true) spawn.lock!(locks) end + # Like #lock, but modifies relation in place. def lock!(locks = true) case locks when String, TrueClass, NilClass @@ -464,6 +478,7 @@ module ActiveRecord spawn.readonly!(value) end + # Like #readonly, but modifies relation in place. def readonly!(value = true) self.readonly_value = value self @@ -513,6 +528,7 @@ module ActiveRecord spawn.from!(value, subquery_name) end + # Like #from, but modifies relation in place. def from!(value, subquery_name = nil) self.from_value = [value, subquery_name] self @@ -532,6 +548,7 @@ module ActiveRecord spawn.uniq!(value) end + # Like #uniq, but modifies relation in place. def uniq!(value = true) self.uniq_value = value self @@ -581,6 +598,7 @@ module ActiveRecord end end + # Like #extending, but modifies relation in place. def extending!(*modules, &block) modules << Module.new(&block) if block_given? @@ -597,6 +615,7 @@ module ActiveRecord spawn.reverse_order! end + # Like #reverse_order, but modifies relation in place. def reverse_order! self.reverse_order_value = !reverse_order_value self -- cgit v1.2.3 From b64599a6c62ede468810d7176a92dce08d0486b6 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 12:36:52 -0700 Subject: Typo --- activerecord/lib/active_record/relation/query_methods.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index c057a684e6..54179d1fe5 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -86,7 +86,6 @@ module ActiveRecord end # Like #eager_load, but modifies relation in place. - # object. def eager_load!(*args) self.eager_load_values += args self -- cgit v1.2.3 From 9887440a0c0e69afbcd6ccba4243033fb153c8cb Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 22:45:33 -0700 Subject: Don't link to edgeguides in docs --- activerecord/lib/active_record/relation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index dd1f77e925..05bf3d954c 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -145,7 +145,7 @@ module ActiveRecord # are needed by the next ones when eager loading is going on. # # Please see further details in the - # {Active Record Query Interface guide}[http://edgeguides.rubyonrails.org/active_record_querying.html#running-explain]. + # {Active Record Query Interface guide}[http://guides.rubyonrails.org/active_record_querying.html#running-explain]. def explain _, queries = collecting_queries_for_explain { exec_queries } exec_explain(queries) -- cgit v1.2.3 From 5edbeb0a87f89f1a51c71afbf248e7fa57891b3c Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 16 Jul 2012 23:17:22 -0700 Subject: Add docs for Relation initialize, create and create! --- activerecord/lib/active_record/relation.rb | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 05bf3d954c..999a38011c 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -75,6 +75,18 @@ module ActiveRecord binds) end + # Initializes new record from relation while maintaing the current + # scope. + # + # Expects arguments in the same format as +Base.new+. + # + # users = User.where(name: 'DHH') + # user = users.new # => # + # + # You can also pass a block to new with the new record as argument: + # + # user = users.new { |user| user.name = 'Oscar' } + # user.name # => Oscar def new(*args, &block) scoping { @klass.new(*args, &block) } end @@ -87,17 +99,38 @@ module ActiveRecord alias build new + # Tries to +create+ a new record with the same scoped attributes + # defined in the relation. Returns the initialized object if validation fails. + # + # Expects arguments in the same format as +Base.create+. + # + # ==== Examples + # users = User.where(name: 'Oscar') + # users.create # # + # + # users.create(name: 'fxn') + # users.create # # + # + # users.create { |user| user.name = 'tenderlove' } + # # # + # + # users.create(name: nil) # validation on name + # # # def create(*args, &block) scoping { @klass.create(*args, &block) } end + # Similar to #create, but calls +create!+ on the base class. Raises + # an exception if a validation error occurs. + # + # Expects arguments in the same format as Base.create!. def create!(*args, &block) scoping { @klass.create!(*args, &block) } end # Tries to load the first record; if it fails, then create is called with the same arguments as this method. # - # Expects arguments in the same format as Base.create. + # Expects arguments in the same format as +Base.create+. # # ==== Examples # # Find the first user named Penélope or create a new one. -- cgit v1.2.3 From 2c050e1808b996e6a0ff2e26981087d8c080fc48 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 17 Jul 2012 15:48:03 -0700 Subject: Improve docs for AR Relation --- activerecord/lib/active_record/relation.rb | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 999a38011c..6f8f3259a4 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -184,6 +184,7 @@ module ActiveRecord exec_explain(queries) end + # Converts relation objects to Array. def to_a # We monitor here the entire execution rather than individual SELECTs # because from the point of view of the user fetching the records of a @@ -242,6 +243,7 @@ module ActiveRecord c.respond_to?(:zero?) ? c.zero? : c.empty? end + # Returns true if there are any records. def any? if block_given? to_a.any? { |*block_args| yield(*block_args) } @@ -250,6 +252,7 @@ module ActiveRecord end end + # Returns true if there are more than one records. def many? if block_given? to_a.many? { |*block_args| yield(*block_args) } @@ -283,17 +286,14 @@ module ActiveRecord # ==== Parameters # # * +updates+ - A string, array, or hash representing the SET part of an SQL statement. - # * +conditions+ - A string, array, or hash representing the WHERE part of an SQL statement. - # See conditions in the intro. - # * +options+ - Additional options are :limit and :order, see the examples for usage. # # ==== Examples # # # Update all customers with the given attributes - # Customer.update_all :wants_email => true + # Customer.update_all wants_email: true # # # Update all books with 'Rails' in their title - # Book.where('title LIKE ?', '%Rails%').update_all(:author => 'David') + # Book.where('title LIKE ?', '%Rails%').update_all(author: 'David') # # # Update all books that match conditions, but limit it to 5 ordered by date # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(:author => 'David') @@ -326,7 +326,7 @@ module ActiveRecord # ==== Examples # # # Updates one record - # Person.update(15, :user_name => 'Samuel', :group => 'expert') + # Person.update(15, user_name: 'Samuel', group: 'expert') # # # Updates multiple records # people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } } @@ -366,7 +366,7 @@ module ActiveRecord # ==== Examples # # Person.destroy_all("last_login < '2004-04-04'") - # Person.destroy_all(:status => "inactive") + # Person.destroy_all(status: "inactive") # Person.where(:age => 0..18).destroy_all def destroy_all(conditions = nil) if conditions @@ -468,6 +468,7 @@ module ActiveRecord where(primary_key => id_or_array).delete_all end + # Forces reloading of relation. def reload reset to_a # force reload @@ -481,10 +482,18 @@ module ActiveRecord self end + # Returns sql statement for the relation. + # + # Users.where(name: 'Oscar').to_sql + # # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar' def to_sql @to_sql ||= klass.connection.to_sql(arel, bind_values.dup) end + # Returns an hash of where conditions + # + # Users.where(name: 'Oscar').to_sql + # # => {: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 @@ -502,6 +511,7 @@ module ActiveRecord @scope_for_create ||= where_values_hash.merge(create_with_value) end + # Returns true if relation needs eager loading. def eager_loading? @should_eager_load ||= eager_load_values.any? || @@ -516,6 +526,7 @@ module ActiveRecord includes_values & joins_values end + # Compares two relations for equality. def ==(other) case other when Relation @@ -539,6 +550,7 @@ module ActiveRecord end end + # Returns true if relation is blank> def blank? to_a.blank? end -- cgit v1.2.3 From 30bf42b3ef8be104abffba07c3feaa343d882e09 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 17 Jul 2012 15:53:36 -0700 Subject: Fix typos and add nodocs to NullRelation --- activerecord/lib/active_record/null_relation.rb | 2 +- activerecord/lib/active_record/relation.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index aca8291d75..741ec31646 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -2,7 +2,7 @@ module ActiveRecord # = Active Record Null Relation - module NullRelation + module NullRelation # :nodoc: def exec_queries @records = [] end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 6f8f3259a4..cc03ebf5d6 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -490,9 +490,9 @@ module ActiveRecord @to_sql ||= klass.connection.to_sql(arel, bind_values.dup) end - # Returns an hash of where conditions + # Returns a hash of where conditions # - # Users.where(name: 'Oscar').to_sql + # Users.where(name: 'Oscar').where_values_hash # # => {:name=>"oscar"} def where_values_hash equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node| @@ -550,7 +550,7 @@ module ActiveRecord end end - # Returns true if relation is blank> + # Returns true if relation is blank. def blank? to_a.blank? end -- cgit v1.2.3 From 28e534136f1d4a496eb39d752896603f6ef5d6ff Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 17 Jul 2012 16:04:52 -0700 Subject: Add nodoc to HashMerger and Merger --- activerecord/lib/active_record/relation/merger.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb index 36f98c6480..b04dd7c6a7 100644 --- a/activerecord/lib/active_record/relation/merger.rb +++ b/activerecord/lib/active_record/relation/merger.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/hash/keys' module ActiveRecord class Relation - class HashMerger + class HashMerger # :nodoc: attr_reader :relation, :hash def initialize(relation, hash) @@ -28,7 +28,7 @@ module ActiveRecord end end - class Merger + class Merger # :nodoc: attr_reader :relation, :values def initialize(relation, other) -- cgit v1.2.3 From 21123d3a7d4f87c9e61462248e3e5c7c7af1438f Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 17 Jul 2012 16:10:27 -0700 Subject: Update batches docs --- activerecord/lib/active_record/relation/batches.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/relation/batches.rb b/activerecord/lib/active_record/relation/batches.rb index fb4388d4b2..5b78b246ab 100644 --- a/activerecord/lib/active_record/relation/batches.rb +++ b/activerecord/lib/active_record/relation/batches.rb @@ -9,8 +9,8 @@ module ActiveRecord # In that case, batch processing methods allow you to work # with the records in batches, thereby greatly reducing memory consumption. # - # The find_each method uses find_in_batches with a batch size of 1000 (or as - # specified by the :batch_size option). + # The #find_each method uses #find_in_batches with a batch size of 1000 (or as + # specified by the +:batch_size+ option). # # Person.all.find_each do |person| # person.do_awesome_stuff @@ -20,7 +20,7 @@ module ActiveRecord # person.party_all_night! # end # - # You can also pass the :start option to specify + # You can also pass the +:start+ option to specify # an offset to control the starting point. def find_each(options = {}) find_in_batches(options) do |records| @@ -29,14 +29,14 @@ module ActiveRecord end # Yields each batch of records that was found by the find +options+ as - # an array. The size of each batch is set by the :batch_size + # an array. The size of each batch is set by the +:batch_size+ # option; the default is 1000. # # You can control the starting point for the batch processing by - # supplying the :start option. This is especially useful if you + # supplying the +:start+ option. This is especially useful if you # want multiple workers dealing with the same processing queue. You can # make worker 1 handle all the records between id 0 and 10,000 and - # worker 2 handle from 10,000 and beyond (by setting the :start + # worker 2 handle from 10,000 and beyond (by setting the +:start+ # option on that worker). # # It's not possible to set the order. That is automatically set to -- cgit v1.2.3 From 27014bbf513ebb2dde143ebd745283496e7db558 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 17 Jul 2012 16:21:22 -0700 Subject: Add nodocs to delegation module and docs for merge! --- activerecord/lib/active_record/relation/delegation.rb | 2 +- activerecord/lib/active_record/relation/spawn_methods.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index 64dda4f35a..a1c7e5b549 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -1,7 +1,7 @@ require 'active_support/core_ext/module/delegation' module ActiveRecord - module Delegation + module Delegation # :nodoc: # Set up common delegations for performance (avoids method_missing) delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to_ary, :to => :to_a delegate :table_name, :quoted_table_name, :primary_key, :quoted_primary_key, diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 80d087a9ea..d21f02cd5f 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -34,6 +34,7 @@ module ActiveRecord end end + # Like #merge, but applies changes in place. def merge!(other) klass = other.is_a?(Hash) ? Relation::HashMerger : Relation::Merger klass.new(self, other).merge -- cgit v1.2.3 From 69879667dcf4494915f1b9d826f17856bff11887 Mon Sep 17 00:00:00 2001 From: Erich Kist Date: Thu, 19 Jul 2012 14:19:43 -0300 Subject: Fix a reference --- activesupport/lib/active_support/hash_with_indifferent_access.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 3e6c8893e9..a6796d44f0 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -96,7 +96,7 @@ module ActiveSupport alias_method :has_key?, :key? alias_method :member?, :key? - # Fetches the value for the specified key, same as doing hash[key] + # Fetches the value for the specified key, same as doing hash[key] def fetch(key, *extras) super(convert_key(key), *extras) end -- cgit v1.2.3 From 11d488dd7a5adf1c5c5044ee2cdd96e127e67cd4 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Thu, 19 Jul 2012 11:16:02 -0700 Subject: Fix typos --- activerecord/lib/active_record/relation.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index cc03ebf5d6..3095580b66 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -75,7 +75,7 @@ module ActiveRecord binds) end - # Initializes new record from relation while maintaing the current + # Initializes new record from relation while maintaining the current # scope. # # Expects arguments in the same format as +Base.new+. @@ -99,7 +99,7 @@ module ActiveRecord alias build new - # Tries to +create+ a new record with the same scoped attributes + # Tries to create a new record with the same scoped attributes # defined in the relation. Returns the initialized object if validation fails. # # Expects arguments in the same format as +Base.create+. @@ -252,7 +252,7 @@ module ActiveRecord end end - # Returns true if there are more than one records. + # Returns true if there is more than one records. def many? if block_given? to_a.many? { |*block_args| yield(*block_args) } -- cgit v1.2.3 From 5a6f30ff0f11f6d685d2601a60700784e3555b8b Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Fri, 20 Jul 2012 09:44:54 +0200 Subject: Make it clear that you can also pass a full url to assert_routing. --- actionpack/lib/action_dispatch/testing/assertions/routing.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 9de545b3c5..2e971cffe1 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -37,6 +37,9 @@ module ActionDispatch # # # Test a custom route # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1') + # + # # Path can be a full url (with ://) to test routing based on constrains such as subdomain or host + # assert_routing 'http://api.example.com/', :controller => 'api', :action => 'index' def assert_recognizes(expected_options, path, extras={}, message=nil) request = recognized_request_for(path, extras) -- cgit v1.2.3 From b6693532e90bc95b2d5a4ad0a87a1339ed3758bc Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 21 Jul 2012 08:08:30 +0200 Subject: Revert "Fix a reference" The sentence itself was not exact, [] and fetch are different. Reverting in docrails because it has been reworded in master and 3-2-stable,see 98f4aee8dac22d9e9bb3c122b43e9e5ee8ba7d1c. This reverts commit 69879667dcf4494915f1b9d826f17856bff11887. --- activesupport/lib/active_support/hash_with_indifferent_access.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index a6796d44f0..3e6c8893e9 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -96,7 +96,7 @@ module ActiveSupport alias_method :has_key?, :key? alias_method :member?, :key? - # Fetches the value for the specified key, same as doing hash[key] + # Fetches the value for the specified key, same as doing hash[key] def fetch(key, *extras) super(convert_key(key), *extras) end -- cgit v1.2.3 From 60df591ccaf2338f7f47de8bb28a318db2cfc397 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 21 Jul 2012 21:16:49 +0530 Subject: Revert "Make it clear that you can also pass a full url to assert_routing." This reverts commit 5a6f30ff0f11f6d685d2601a60700784e3555b8b. --- actionpack/lib/action_dispatch/testing/assertions/routing.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 2e971cffe1..9de545b3c5 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -37,9 +37,6 @@ module ActionDispatch # # # Test a custom route # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1') - # - # # Path can be a full url (with ://) to test routing based on constrains such as subdomain or host - # assert_routing 'http://api.example.com/', :controller => 'api', :action => 'index' def assert_recognizes(expected_options, path, extras={}, message=nil) request = recognized_request_for(path, extras) -- cgit v1.2.3 From c851deff83076b8f73c77818bc04ba8e9f7ec335 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 21 Jul 2012 21:44:16 +0530 Subject: minor copy edits [ci skip] --- activerecord/lib/active_record/relation.rb | 4 +--- activerecord/lib/active_record/relation/query_methods.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 3095580b66..3821c6122a 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -252,7 +252,7 @@ module ActiveRecord end end - # Returns true if there is more than one records. + # Returns true if there is more than one record. def many? if block_given? to_a.many? { |*block_args| yield(*block_args) } @@ -263,8 +263,6 @@ module ActiveRecord # Scope all queries to the current scope. # - # ==== Example - # # Comment.where(:post_id => 1).scoping do # Comment.first # SELECT * FROM comments WHERE post_id = 1 # end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 54179d1fe5..4591c8f41f 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -504,7 +504,7 @@ module ActiveRecord # +ImmutableRelation+ if the relation has already been loaded. # # users = User.scoped.create_with!(name: 'Oscar') - # users.name # => 'Oscar' + # users.new.name # => 'Oscar' def create_with!(value) self.create_with_value = value ? create_with_value.merge(value) : {} self -- cgit v1.2.3 From 8fe5f01c31c489548f1648b1c3269c2d1cb5e178 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 21 Jul 2012 21:45:32 +0530 Subject: improve NullRelation docs [ci skip] --- activerecord/lib/active_record/null_relation.rb | 1 - activerecord/lib/active_record/relation/query_methods.rb | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 741ec31646..4c1c91e3df 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- module ActiveRecord - # = Active Record Null Relation module NullRelation # :nodoc: def exec_queries @records = [] diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 4591c8f41f..9df63d5485 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -435,11 +435,11 @@ module ActiveRecord end # Returns a chainable relation with zero records, specifically an - # instance of the NullRelation class. + # instance of the ActiveRecord::NullRelation class. # - # The returned NullRelation inherits from Relation and implements the - # Null Object pattern so it is an object with defined null behavior: - # it always returns an empty array of records and does not query the database. + # The returned ActiveRecord::NullRelation inherits from Relation and implements the + # Null Object pattern. It is an object with defined null behavior and always returns an empty + # array of records without quering the database. # # Any subsequent condition chained to the returned relation will continue # generating an empty relation and will not fire any query to the database. -- cgit v1.2.3