From 4736c14fdb6ad1071308001040f3b11c5af1cd29 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 11:49:14 -0500 Subject: nodoc deprecated AR::Fixtures constant [ci skip] --- activerecord/lib/active_record/fixtures.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 413bd147de..7f1d62af39 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -657,6 +657,7 @@ module ActiveRecord #-- # Deprecate 'Fixtures' in favor of 'FixtureSet'. #++ + # :nodoc: Fixtures = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveRecord::Fixtures', 'ActiveRecord::FixtureSet') class Fixture #:nodoc: -- cgit v1.2.3 From 06e908c4e13a0f87f05f6115e13e6f5b8d20d499 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 13:46:41 -0500 Subject: Fix AR::AttributeMethods#[] example [ci skip] --- activerecord/lib/active_record/attribute_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 008696f6de..ca95329186 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -271,7 +271,7 @@ module ActiveRecord # class Person < ActiveRecord::Base # end # - # person = Person.new(name: 'Francesco', age: '22' + # person = Person.new(name: 'Francesco', age: '22') # person[:name] # => "Francesco" # person[:age] # => 22 def [](attr_name) -- cgit v1.2.3 From c6fb832fe883ac996c0fa773ee2b5c9fdc2c9f62 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 14:06:53 -0500 Subject: update AR::AttributeMethods::BeforeTypeCast docs [ci skip] --- .../attribute_methods/before_type_cast.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb index d4f529acbf..030972fc8a 100644 --- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb @@ -7,11 +7,29 @@ module ActiveRecord attribute_method_suffix "_before_type_cast" end + # Returns the value of the attribuet identified by +attr_name+ before + # typecasting and deserialization. + # + # class Task < ActiveRecord::Base + # end + # + # task = Task.new(id: '1', completed_on: '2012-10-21') + # task.read_attribute('id') # => 1 + # task.read_attribute_before_type_cast('id') # => '1' + # task.read_attribute('completed_on') # => Sun, 21 Oct 2012 + # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21" def read_attribute_before_type_cast(attr_name) @attributes[attr_name] end # Returns a hash of attributes before typecasting and deserialization. + # + # class Task < ActiveRecord::Base + # end + # + # task = Task.new(title: nil, is_done: true, completed_on: '2012-10-21') + # task.attributes_before_type_cast + # # => {"id"=>nil, "title"=>nil, "is_done"=>true, "completed_on"=>"2012-10-21", "created_at"=>nil, "updated_at"=>nil} def attributes_before_type_cast @attributes end -- cgit v1.2.3 From e32bbc1356a7e72f721373344202c3d63fc37312 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 14:12:01 -0500 Subject: fix typo and improve example [ci skip] --- activerecord/lib/active_record/attribute_methods/before_type_cast.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb index 030972fc8a..7fe5411a3b 100644 --- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb @@ -7,7 +7,7 @@ module ActiveRecord attribute_method_suffix "_before_type_cast" end - # Returns the value of the attribuet identified by +attr_name+ before + # Returns the value of the attribute identified by +attr_name+ before # typecasting and deserialization. # # class Task < ActiveRecord::Base @@ -28,6 +28,8 @@ module ActiveRecord # end # # task = Task.new(title: nil, is_done: true, completed_on: '2012-10-21') + # task.attributes + # # => {"id"=>nil, "title"=>nil, "is_done"=>true, "completed_on"=>Sun, 21 Oct 2012, "created_at"=>nil, "updated_at"=>nil} # task.attributes_before_type_cast # # => {"id"=>nil, "title"=>nil, "is_done"=>true, "completed_on"=>"2012-10-21", "created_at"=>nil, "updated_at"=>nil} def attributes_before_type_cast -- cgit v1.2.3 From bc3f960c0f3b3d88f024969f4606317040cb2332 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 19:20:18 -0500 Subject: improve AR::AttributeMethods documentation [ci skip] --- activerecord/lib/active_record/attribute_methods.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index ca95329186..0118bbd6b6 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -215,10 +215,10 @@ module ActiveRecord # person = Person.create!(name: 'David Heinemeier Hansson ' * 3) # # person.attribute_for_inspect(:name) - # # => '"David Heinemeier Hansson David Heinemeier Hansson D..."' + # # => "\"David Heinemeier Hansson David Heinemeier Hansson D...\"" # # person.attribute_for_inspect(:created_at) - # # => '"2009-01-12 04:48:57"' + # # => "\"2012-10-22 00:15:07\"" def attribute_for_inspect(attr_name) value = read_attribute(attr_name) @@ -234,14 +234,18 @@ module ActiveRecord # Returns +true+ if the specified +attribute+ has been set by the user or by a # database load and is neither +nil+ nor empty? (the latter only applies # to objects that respond to empty?, most notably Strings). Otherwise, +false+. + # Note that it always returns +true+ with boolean attributes. # - # class Person < ActiveRecord::Base + # class Task < ActiveRecord::Base # end # - # person = Person.new(name: '') - # person.attribute_present?(:name) # => false + # person = Task.new(title: '', is_done: false) + # person.attribute_present?(:title) # => false + # person.attribute_present?(:is_done) # => true # person.name = 'Francesco' - # person.attribute_present?(:name) # => true + # person.is_done = true + # person.attribute_present?(:title) # => true + # person.attribute_present?(:is_done) # => true def attribute_present?(attribute) value = read_attribute(attribute) !value.nil? && !(value.respond_to?(:empty?) && value.empty?) -- cgit v1.2.3 From 1e5a6c7855e6ce7d5a9c4c53a326488bd0e3fb08 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 19:46:10 -0500 Subject: add docs to AR::AttributeMethods::BeforeTypeCast [ci skip] --- .../attribute_methods/before_type_cast.rb | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb index 7fe5411a3b..faee99ccd1 100644 --- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb @@ -1,5 +1,28 @@ module ActiveRecord module AttributeMethods + # = Active Record Attribute Methods Before Type Cast + # + # ActiveRecord::AttributeMethods::BeforeTypeCast provides a way to + # read the value of the attributes before typecasting and deserialization. + # + # class Task < ActiveRecord::Base + # end + # + # task = Task.new(id: '1', completed_on: '2012-10-21') + # task.id # => 1 + # task.completed_on # => Sun, 21 Oct 2012 + # + # task.attributes_before_type_cast + # # => {"id"=>"1", "completed_on"=>"2012-10-21", ... } + # task.read_attribute_before_type_cast('id') # => 1 + # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21" + # + # In addition to #read_attribute_before_type_cast and #attributes_before_type_cast, + # it declares a method for all attributes with the *_before_type_cast + # suffix. + # + # task.id_before_type_cast # => "1" + # task.completed_on_before_type_cast # => "2012-10-21" module BeforeTypeCast extend ActiveSupport::Concern -- cgit v1.2.3 From ae27acb342c575ce19d5ad78cb13ba23f826fab1 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 21 Oct 2012 20:04:41 -0500 Subject: =?UTF-8?q?read=5Fattribute=20is=20public=C2=A0[ci=20skip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activerecord/lib/active_record/attribute_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 0118bbd6b6..1dd9a3d45d 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -270,7 +270,7 @@ module ActiveRecord # Returns the value of the attribute identified by attr_name after it has been typecast (for example, # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). - # (Alias for the protected read_attribute method). + # (Alias for read_attribute). # # class Person < ActiveRecord::Base # end -- cgit v1.2.3 From 3e6b2f5d38e0f31db3fb0fcd3bbab92666a0e3e2 Mon Sep 17 00:00:00 2001 From: Pablo Ifran Date: Mon, 22 Oct 2012 09:38:57 -0200 Subject: Changeing some code-styles of the examples & fix a typo on dependent option --- activerecord/lib/active_record/callbacks.rb | 30 ++++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index 9626df08aa..188a06e448 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -204,43 +204,37 @@ module ActiveRecord # # Sometimes the code needs that the callbacks execute in a specific order. For example, a +before_destroy+ # callback (log_children in this case) should be executed before the children get destroyed by the - # dependant destroy option. + # dependent destroy option. # # Let's take at the code below: # # class Topic < ActiveRecord::Base - # - # has_many :children, dependant: destroy + # has_many :children, dependent: destroy # # before_destroy :log_children # - # def log_children - # children.each do |child| - # # Some child processing + # private + # def log_children + # # Child processing # end - # end - # # end # # In this case the problem is that when the +before_destroy+ is executed, the children are not available - # because the dependant destroy gets executed first. To solve this issue it is possible - # to use the +prepend+ option on the +before_destroy+ callback. + # because the dependent destroy gets executed first. To solve this issue it is possible to use the + # +prepend+ option on the +before_destroy+ callback. # # class Topic < ActiveRecord::Base - # - # has_many :children, dependant: destroy + # has_many :children, dependent: destroy # # before_destroy :log_children, prepend: true # - # def log_children - # children.each do |child| - # # Some child processing + # private + # def log_children + # # Child processing # end - # end - # # end # - # This way, the +before_destroy+ gets executed before the dependant: destroy is called, and + # This way, the +before_destroy+ gets executed before the dependent: destroy is called, and # the data is still available. # # == Transactions -- cgit v1.2.3 From 01e38d8c89b4568a96ac10eefe8c3be2a3abf7ab Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Mon, 22 Oct 2012 22:49:01 +0800 Subject: Fix code example in AR::AttributeMethods::BeforeTypeCast. --- activerecord/lib/active_record/attribute_methods/before_type_cast.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb index faee99ccd1..a23baeaced 100644 --- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb +++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb @@ -14,7 +14,7 @@ module ActiveRecord # # task.attributes_before_type_cast # # => {"id"=>"1", "completed_on"=>"2012-10-21", ... } - # task.read_attribute_before_type_cast('id') # => 1 + # task.read_attribute_before_type_cast('id') # => "1" # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21" # # In addition to #read_attribute_before_type_cast and #attributes_before_type_cast, -- cgit v1.2.3 From 6004fd336a95b2f951042d9c231f58b762582e75 Mon Sep 17 00:00:00 2001 From: Luis M Date: Tue, 23 Oct 2012 01:05:00 -0500 Subject: Fixed typo on ActiveRecord nested_attributes. --- activerecord/lib/active_record/nested_attributes.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 2e7fb3bbb3..43f908ae5f 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -109,7 +109,7 @@ module ActiveRecord # ] # }} # - # member = Member.create(params['member']) + # member = Member.create(params[:member]) # member.posts.length # => 2 # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' @@ -131,7 +131,7 @@ module ActiveRecord # ] # }} # - # member = Member.create(params['member']) + # member = Member.create(params[:member]) # member.posts.length # => 2 # member.posts.first.title # => 'Kari, the awesome Ruby documentation browser!' # member.posts.second.title # => 'The egalitarian assumption of the modern citizen' @@ -181,7 +181,7 @@ module ActiveRecord # :posts_attributes => [{ :id => '2', :_destroy => '1' }] # }} # - # member.attributes = params['member'] + # member.attributes = params[:member] # member.posts.detect { |p| p.id == 2 }.marked_for_destruction? # => true # member.posts.length # => 2 # member.save -- cgit v1.2.3 From 30d2627cff29252efe4d711bb9d9bc2b1719293c Mon Sep 17 00:00:00 2001 From: AvnerCohen Date: Tue, 23 Oct 2012 13:02:34 +0200 Subject: Another batch of hash syntax changes to comment, this time around, I tried to keep 'output' messages untouched. --- activerecord/lib/active_record/persistence.rb | 18 +++++++++--------- activerecord/lib/active_record/reflection.rb | 24 ++++++++++++------------ activerecord/lib/active_record/relation.rb | 10 +++++----- 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 611d3d97c3..65a31f1566 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -15,18 +15,18 @@ module ActiveRecord # # ==== Examples # # Create a single new object - # User.create(:first_name => 'Jamie') + # User.create(first_name: 'Jamie') # # # Create an Array of new objects - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) + # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) # # # Create a single object and pass it into a block to set other attributes. - # User.create(:first_name => 'Jamie') do |u| + # User.create(first_name: 'Jamie') do |u| # u.is_admin = false # end # # # Creating an Array of new objects using a block, where the block is executed for each object: - # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u| + # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u| # u.is_admin = false # end def create(attributes = nil, &block) @@ -64,7 +64,7 @@ module ActiveRecord # # By default, save always run validations. If any of them fail the action # is cancelled and +save+ returns +false+. However, if you supply - # :validate => false, validations are bypassed altogether. See + # validate: false, validations are bypassed altogether. See # ActiveRecord::Validations for more information. # # There's a series of callbacks associated with +save+. If any of the @@ -143,7 +143,7 @@ module ActiveRecord # inheritance structures where you want a subclass to appear as the # superclass. This can be used along with record identification in # Action Pack to allow, say, Client < Company to do something - # like render :partial => @client.becomes(Company) to render that + # like render partial: @client.becomes(Company) to render that # instance using the companies/company partial instead of clients/client. # # Note: The new instance will share a link to the same attributes as the original class. @@ -284,7 +284,7 @@ module ActiveRecord # Reloads the attributes of this object from the database. # The optional options argument is passed to find when reloading so you - # may do e.g. record.reload(:lock => true) to reload the same record with + # may do e.g. record.reload(lock: true) to reload the same record with # an exclusive row lock. def reload(options = nil) clear_aggregation_cache @@ -315,11 +315,11 @@ module ActiveRecord # If used along with +belongs_to+ then +touch+ will invoke +touch+ method on associated object. # # class Brake < ActiveRecord::Base - # belongs_to :car, :touch => true + # belongs_to :car, touch: true # end # # class Car < ActiveRecord::Base - # belongs_to :corporation, :touch => true + # belongs_to :corporation, touch: true # end # # # triggers @brake.car.touch and @brake.car.corporation.touch diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index f322b96f79..0103de4cbd 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -81,13 +81,13 @@ module ActiveRecord class MacroReflection # Returns the name of the macro. # - # composed_of :balance, :class_name => 'Money' returns :balance + # composed_of :balance, class_name: 'Money' returns :balance # has_many :clients returns :clients attr_reader :name # Returns the macro type. # - # composed_of :balance, :class_name => 'Money' returns :composed_of + # composed_of :balance, class_name: 'Money' returns :composed_of # has_many :clients returns :has_many attr_reader :macro @@ -95,7 +95,7 @@ module ActiveRecord # Returns the hash of options used for the macro. # - # composed_of :balance, :class_name => 'Money' returns { :class_name => "Money" } + # composed_of :balance, class_name: 'Money' returns { class_name: "Money" } # has_many :clients returns +{}+ attr_reader :options @@ -115,7 +115,7 @@ module ActiveRecord # Returns the class for the macro. # - # composed_of :balance, :class_name => 'Money' returns the Money class + # composed_of :balance, class_name: 'Money' returns the Money class # has_many :clients returns the Client class def klass @klass ||= class_name.constantize @@ -123,7 +123,7 @@ module ActiveRecord # Returns the class name for the macro. # - # composed_of :balance, :class_name => 'Money' returns 'Money' + # composed_of :balance, class_name: 'Money' returns 'Money' # has_many :clients returns 'Client' def class_name @class_name ||= (options[:class_name] || derive_class_name).to_s @@ -315,10 +315,10 @@ module ActiveRecord # the parent's validation. # # Unless you explicitly disable validation with - # :validate => false, validation will take place when: + # validate: false, validation will take place when: # - # * you explicitly enable validation; :validate => true - # * you use autosave; :autosave => true + # * you explicitly enable validation; validate: true + # * you use autosave; autosave: true # * the association is a +has_many+ association def validate? !options[:validate].nil? ? options[:validate] : (options[:autosave] == true || macro == :has_many) @@ -399,7 +399,7 @@ module ActiveRecord # # class Post < ActiveRecord::Base # has_many :taggings - # has_many :tags, :through => :taggings + # has_many :tags, through: :taggings # end # def source_reflection @@ -411,7 +411,7 @@ module ActiveRecord # # class Post < ActiveRecord::Base # has_many :taggings - # has_many :tags, :through => :taggings + # has_many :tags, through: :taggings # end # # tags_reflection = Post.reflect_on_association(:tags) @@ -439,12 +439,12 @@ module ActiveRecord # # class Person # has_many :articles - # has_many :comment_tags, :through => :articles + # has_many :comment_tags, through: :articles # end # # class Article # has_many :comments - # has_many :comment_tags, :through => :comments, :source => :tags + # has_many :comment_tags, through: :comments, source: :tags # end # # class Comment diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 2e2286e4fd..cb9cc5a9df 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -235,7 +235,7 @@ module ActiveRecord # Scope all queries to the current scope. # - # Comment.where(:post_id => 1).scoping do + # Comment.where(post_id: 1).scoping do # Comment.first # SELECT * FROM comments WHERE post_id = 1 # end # @@ -266,7 +266,7 @@ module ActiveRecord # 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') + # Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(author: 'David') def update_all(updates) raise ArgumentError, "Empty list of attributes to change" if updates.blank? @@ -339,7 +339,7 @@ module ActiveRecord # # Person.destroy_all("last_login < '2004-04-04'") # Person.destroy_all(status: "inactive") - # Person.where(:age => 0..18).destroy_all + # Person.where(age: 0..18).destroy_all def destroy_all(conditions = nil) if conditions where(conditions).destroy_all @@ -384,7 +384,7 @@ module ActiveRecord # # Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')") # Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else']) - # Post.where(:person_id => 5).where(:category => ['Something', 'Else']).delete_all + # Post.where(person_id: 5).where(category: ['Something', 'Else']).delete_all # # Both calls delete the affected posts all at once with a single DELETE statement. # If you need to destroy dependent associations or call your before_* or @@ -514,7 +514,7 @@ module ActiveRecord # Joins that are also marked for preloading. In which case we should just eager load them. # Note that this is a naive implementation because we could have strings and symbols which # represent the same association, but that aren't matched by this. Also, we could have - # nested hashes which partially match, e.g. { :a => :b } & { :a => [:b, :c] } + # nested hashes which partially match, e.g. { a: :b } & { a: [:b, :c] } def joined_includes_values includes_values & joins_values end -- cgit v1.2.3 From 3b89052014c2bf3b8fbbcfb93f657a17dd7e7ca3 Mon Sep 17 00:00:00 2001 From: AvnerCohen Date: Tue, 23 Oct 2012 15:59:42 +0200 Subject: Updated activerecord test comments to new hash syntax --- activerecord/test/cases/base_test.rb | 4 ++-- .../test/cases/validations/i18n_generate_message_validation_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 0f859bf452..65e8ccdbc8 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -838,7 +838,7 @@ class BasicsTest < ActiveRecord::TestCase g = Geometric.new( :a_point => '(5.0, 6.1)', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql + #a_line: '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql :a_line_segment => '(2.0, 3), (5.5, 7.0)', :a_box => '2.0, 3, 5.5, 7.0', :a_path => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]', # [ ] is an open path @@ -867,7 +867,7 @@ class BasicsTest < ActiveRecord::TestCase g = Geometric.new( :a_point => '5.0, 6.1', - #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql + #a_line: '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql :a_line_segment => '((2.0, 3), (5.5, 7.0))', :a_box => '(2.0, 3), (5.5, 7.0)', :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', # ( ) is a closed path diff --git a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb index 174d96aa4e..5af9733a68 100644 --- a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb @@ -18,7 +18,7 @@ class I18nGenerateMessageValidationTest < ActiveRecord::TestCase I18n.backend = @old_backend end - # validates_associated: generate_message(attr_name, :invalid, :message => custom_message, :value => value) + # validates_associated: generate_message(attr_name, :invalid, message: custom_message, value: value) def test_generate_message_invalid_with_default_message assert_equal 'is invalid', @topic.errors.generate_message(:title, :invalid, :value => 'title') end @@ -27,7 +27,7 @@ class I18nGenerateMessageValidationTest < ActiveRecord::TestCase assert_equal 'custom message title', @topic.errors.generate_message(:title, :invalid, :message => 'custom message %{value}', :value => 'title') end - # validates_uniqueness_of: generate_message(attr_name, :taken, :message => custom_message) + # validates_uniqueness_of: generate_message(attr_name, :taken, message: custom_message) def test_generate_message_taken_with_default_message assert_equal "has already been taken", @topic.errors.generate_message(:title, :taken, :value => 'title') end -- cgit v1.2.3 From 9edd4e18c411e6834569bbe7b6350f02342970d8 Mon Sep 17 00:00:00 2001 From: AvnerCohen Date: Tue, 23 Oct 2012 22:39:49 +0200 Subject: Migration of docs to 1.9 hash syntax --- .../lib/active_record/associations/preloader.rb | 6 +-- .../associations/through_association.rb | 2 +- .../abstract/database_statements.rb | 2 +- .../abstract/schema_definitions.rb | 42 +++++++++---------- .../abstract/schema_statements.rb | 48 +++++++++++----------- .../connection_adapters/abstract_mysql_adapter.rb | 4 +- .../connection_adapters/mysql2_adapter.rb | 2 +- .../postgresql/schema_statements.rb | 2 +- 8 files changed, 54 insertions(+), 54 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index c1cd3a4ae3..0848e7afb3 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -72,7 +72,7 @@ module ActiveRecord # books. # - a Hash which specifies multiple association names, as well as # association names for the to-be-preloaded association objects. For - # example, specifying { :author => :avatar } will preload a + # example, specifying { author: :avatar } will preload a # book's author, as well as that author's avatar. # # +:associations+ has the same format as the +:include+ option for @@ -80,8 +80,8 @@ module ActiveRecord # # :books # [ :books, :author ] - # { :author => :avatar } - # [ :books, { :author => :avatar } ] + # { author: :avatar } + # [ :books, { author: :avatar } ] def initialize(records, associations, preload_scope = nil) @records = Array.wrap(records).compact.uniq @associations = Array.wrap(associations) diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb index b9e014735b..43520142bf 100644 --- a/activerecord/lib/active_record/associations/through_association.rb +++ b/activerecord/lib/active_record/associations/through_association.rb @@ -28,7 +28,7 @@ module ActiveRecord # methods which create and delete records on the association. # # We only support indirectly modifying through associations which has a belongs_to source. - # This is the "has_many :tags, :through => :taggings" situation, where the join model + # This is the "has_many :tags, through: :taggings" situation, where the join model # typically has a belongs_to on both side. In other words, associations which could also # be represented as has_and_belongs_to_many associations. # diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index 0d7046a705..4f3eebce7d 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -150,7 +150,7 @@ module ActiveRecord # already-automatically-released savepoints: # # 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! diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index dca355aa93..d61731633a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -161,21 +161,21 @@ module ActiveRecord # td.column(:granted, :boolean) # # granted BOOLEAN # - # td.column(:picture, :binary, :limit => 2.megabytes) + # td.column(:picture, :binary, limit: 2.megabytes) # # => picture BLOB(2097152) # - # td.column(:sales_stage, :string, :limit => 20, :default => 'new', :null => false) + # td.column(:sales_stage, :string, limit: 20, default: 'new', null: false) # # => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL # - # td.column(:bill_gates_money, :decimal, :precision => 15, :scale => 2) + # td.column(:bill_gates_money, :decimal, precision: 15, scale: 2) # # => bill_gates_money DECIMAL(15,2) # - # td.column(:sensor_reading, :decimal, :precision => 30, :scale => 20) + # td.column(:sensor_reading, :decimal, precision: 30, scale: 20) # # => sensor_reading DECIMAL(30,20) # # # While :scale defaults to zero on most databases, it # # probably wouldn't hurt to include it. - # td.column(:huge_integer, :decimal, :precision => 30) + # td.column(:huge_integer, :decimal, precision: 30) # # => huge_integer DECIMAL(30) # # # Defines a column with a database-specific type. @@ -190,11 +190,11 @@ module ActiveRecord # # What can be written like this with the regular calls to column: # - # create_table "products", :force => true do |t| + # create_table "products", force: true do |t| # t.column "shop_id", :integer # t.column "creator_id", :integer - # t.column "name", :string, :default => "Untitled" - # t.column "value", :string, :default => "Untitled" + # t.column "name", :string, default: "Untitled" + # t.column "value", :string, default: "Untitled" # t.column "created_at", :datetime # t.column "updated_at", :datetime # end @@ -203,7 +203,7 @@ module ActiveRecord # # create_table :products do |t| # t.integer :shop_id, :creator_id - # t.string :name, :value, :default => "Untitled" + # t.string :name, :value, default: "Untitled" # t.timestamps # end # @@ -218,17 +218,17 @@ module ActiveRecord # create_table :taggings do |t| # t.integer :tag_id, :tagger_id, :taggable_id # t.string :tagger_type - # t.string :taggable_type, :default => 'Photo' + # t.string :taggable_type, default: 'Photo' # end - # add_index :taggings, :tag_id, :name => 'index_taggings_on_tag_id' + # add_index :taggings, :tag_id, name: 'index_taggings_on_tag_id' # add_index :taggings, [:tagger_id, :tagger_type] # # Can also be written as follows using references: # # create_table :taggings do |t| - # t.references :tag, :index => { :name => 'index_taggings_on_tag_id' } - # t.references :tagger, :polymorphic => true, :index => true - # t.references :taggable, :polymorphic => { :default => 'Photo' } + # t.references :tag, index: { name: 'index_taggings_on_tag_id' } + # t.references :tagger, polymorphic: true, index: true + # t.references :taggable, polymorphic: { default: 'Photo' } # end def column(name, type, options = {}) name = name.to_s @@ -262,7 +262,7 @@ module ActiveRecord # Adds index options to the indexes hash, keyed by column name # This is primarily used to track indexes that need to be created after the table # - # index(:account_id, :name => 'index_projects_on_account_id') + # index(:account_id, name: 'index_projects_on_account_id') def index(column_name, options = {}) indexes[column_name] = options end @@ -365,9 +365,9 @@ module ActiveRecord # ====== Creating a simple index # t.index(:name) # ====== Creating a unique index - # t.index([:branch_id, :party_id], :unique => true) + # t.index([:branch_id, :party_id], unique: true) # ====== Creating a named index - # t.index([:branch_id, :party_id], :unique => true, :name => 'by_branch_party') + # t.index([:branch_id, :party_id], unique: true, name: 'by_branch_party') def index(column_name, options = {}) @base.add_index(@table_name, column_name, options) end @@ -387,7 +387,7 @@ module ActiveRecord # Changes the column's definition according to the new options. # See TableDefinition#column for details of the options you can use. # - # t.change(:name, :string, :limit => 80) + # t.change(:name, :string, limit: 80) # t.change(:description, :text) def change(column_name, type, options = {}) @base.change_column(@table_name, column_name, type, options) @@ -414,11 +414,11 @@ module ActiveRecord # ====== Remove the index_table_name_on_column in the table_name table # t.remove_index :column # ====== Remove the index named index_table_name_on_branch_id in the table_name table - # t.remove_index :column => :branch_id + # t.remove_index column: :branch_id # ====== Remove the index named index_table_name_on_branch_id_and_party_id in the table_name table - # t.remove_index :column => [:branch_id, :party_id] + # t.remove_index column: [:branch_id, :party_id] # ====== Remove the index named by_branch_party in the table_name table - # t.remove_index :name => :by_branch_party + # t.remove_index name: :by_branch_party def remove_index(options = {}) @base.remove_index(@table_name, options) end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 86d6266af9..8790518d37 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -36,10 +36,10 @@ module ActiveRecord # index_exists?(:suppliers, [:company_id, :company_type]) # # # Check a unique index exists - # index_exists?(:suppliers, :company_id, :unique => true) + # index_exists?(:suppliers, :company_id, unique: true) # # # Check an index with a custom name exists - # index_exists?(:suppliers, :company_id, :name => "idx_company_id" + # index_exists?(:suppliers, :company_id, name: "idx_company_id" def index_exists?(table_name, column_name, options = {}) column_names = Array(column_name) index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, :column => column_names) @@ -89,14 +89,14 @@ module ActiveRecord # # table. # # create_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 + # t.column :name, :string, limit: 60 # # Other fields here # end # # === Block form, with shorthand # # You can also use the column types as method calls, rather than calling the column method. # create_table(:suppliers) do |t| - # t.string :name, :limit => 60 + # t.string :name, limit: 60 # # Other fields here # end # @@ -104,7 +104,7 @@ module ActiveRecord # # Creates a table called 'suppliers' with no columns. # create_table(:suppliers) # # Add a column to 'suppliers'. - # add_column(:suppliers, :name, :string, {:limit => 60}) + # add_column(:suppliers, :name, :string, {limit: 60}) # # The +options+ hash can include the following keys: # [:id] @@ -127,15 +127,15 @@ module ActiveRecord # Defaults to false. # # ====== Add a backend specific option to the generated SQL (MySQL) - # create_table(:suppliers, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8') + # create_table(:suppliers, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8') # generates: # CREATE TABLE suppliers ( # id int(11) DEFAULT NULL auto_increment PRIMARY KEY # ) ENGINE=InnoDB DEFAULT CHARSET=utf8 # # ====== Rename the primary key column - # create_table(:objects, :primary_key => 'guid') do |t| - # t.column :name, :string, :limit => 80 + # create_table(:objects, primary_key: 'guid') do |t| + # t.column :name, :string, limit: 80 # end # generates: # CREATE TABLE objects ( @@ -144,7 +144,7 @@ module ActiveRecord # ) # # ====== Do not add a primary key column - # create_table(:categories_suppliers, :id => false) do |t| + # create_table(:categories_suppliers, id: false) do |t| # t.column :category_id, :integer # t.column :supplier_id, :integer # end @@ -193,7 +193,7 @@ module ActiveRecord # Defaults to false. # # ====== Add a backend specific option to the generated SQL (MySQL) - # create_join_table(:assemblies, :parts, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8') + # create_join_table(:assemblies, :parts, options: 'ENGINE=InnoDB DEFAULT CHARSET=utf8') # generates: # CREATE TABLE assemblies_parts ( # assembly_id int NOT NULL, @@ -218,7 +218,7 @@ module ActiveRecord # # # change_table() yields a Table instance # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 + # t.column :name, :string, limit: 60 # # Other column alterations here # end # @@ -231,12 +231,12 @@ module ActiveRecord # # ====== Add a column # change_table(:suppliers) do |t| - # t.column :name, :string, :limit => 60 + # t.column :name, :string, limit: 60 # end # # ====== Add 2 integer columns # change_table(:suppliers) do |t| - # t.integer :width, :height, :null => false, :default => 0 + # t.integer :width, :height, null: false, default: 0 # end # # ====== Add created_at/updated_at columns @@ -253,7 +253,7 @@ module ActiveRecord # # ====== Add a polymorphic foreign key column # change_table(:suppliers) do |t| - # t.belongs_to :company, :polymorphic => true + # t.belongs_to :company, polymorphic: true # end # # Creates company_type(varchar) and company_id(integer) columns @@ -318,7 +318,7 @@ module ActiveRecord # Changes the column's definition according to the new options. # See TableDefinition#column for details of the options you can use. # - # change_column(:suppliers, :name, :string, :limit => 80) + # change_column(:suppliers, :name, :string, limit: 80) # change_column(:accounts, :description, :text) def change_column(table_name, column_name, type, options = {}) raise NotImplementedError, "change_column is not implemented" @@ -352,35 +352,35 @@ module ActiveRecord # CREATE INDEX suppliers_name_index ON suppliers(name) # # ====== Creating a unique index - # add_index(:accounts, [:branch_id, :party_id], :unique => true) + # add_index(:accounts, [:branch_id, :party_id], unique: true) # generates # CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id) # # ====== Creating a named index - # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party') + # add_index(:accounts, [:branch_id, :party_id], unique: true, name: 'by_branch_party') # generates # CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id) # # ====== Creating an index with specific key length - # add_index(:accounts, :name, :name => 'by_name', :length => 10) + # add_index(:accounts, :name, name: 'by_name', length: 10) # generates # CREATE INDEX by_name ON accounts(name(10)) # - # add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15}) + # add_index(:accounts, [:name, :surname], name: 'by_name_surname', length: {name: 10, surname: 15}) # generates # CREATE INDEX by_name_surname ON accounts(name(10), surname(15)) # # Note: SQLite doesn't support index length # # ====== Creating an index with a sort order (desc or asc, asc is the default) - # add_index(:accounts, [:branch_id, :party_id, :surname], :order => {:branch_id => :desc, :party_id => :asc}) + # add_index(:accounts, [:branch_id, :party_id, :surname], order: {branch_id: :desc, party_id: :asc}) # generates # CREATE INDEX by_branch_desc_party ON accounts(branch_id DESC, party_id ASC, surname) # # Note: mysql doesn't yet support index order (it accepts the syntax but ignores it) # # ====== Creating a partial index - # add_index(:accounts, [:branch_id, :party_id], :unique => true, :where => "active") + # add_index(:accounts, [:branch_id, :party_id], unique: true, where: "active") # generates # CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active # @@ -396,11 +396,11 @@ module ActiveRecord # Remove the index_accounts_on_column in the accounts table. # remove_index :accounts, :column # Remove the index named index_accounts_on_branch_id in the accounts table. - # remove_index :accounts, :column => :branch_id + # remove_index :accounts, column: :branch_id # Remove the index named index_accounts_on_branch_id_and_party_id in the accounts table. - # remove_index :accounts, :column => [:branch_id, :party_id] + # remove_index :accounts, column: [:branch_id, :party_id] # Remove the index named by_branch_party in the accounts table. - # remove_index :accounts, :name => :by_branch_party + # remove_index :accounts, name: :by_branch_party def remove_index(table_name, options = {}) remove_index!(table_name, index_name_for_remove(table_name, options)) end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index b0e7bd7e82..7da77af3a9 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -353,9 +353,9 @@ module ActiveRecord # Charset defaults to utf8. # # Example: - # create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin' + # create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin' # create_database 'matt_development' - # create_database 'matt_development', :charset => :big5 + # create_database 'matt_development', charset: :big5 def create_database(name, options = {}) if options[:collation] execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`" diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index 879eec7fcf..f55d19393c 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -175,7 +175,7 @@ module ActiveRecord # # as values. # def select_one(sql, name = nil) # result = execute(sql, name) - # result.each(:as => :hash) do |r| + # result.each(as: :hash) do |r| # return r # end # end diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 7cad8f94cf..82a0b662f4 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -16,7 +16,7 @@ module ActiveRecord # # Example: # create_database config[:database], config - # create_database 'foo_development', :encoding => 'unicode' + # create_database 'foo_development', encoding: 'unicode' def create_database(name, options = {}) options = options.reverse_merge(:encoding => "utf8") -- cgit v1.2.3 From 211accced6ccd457f54650bc3b7cf184f8ca0bba Mon Sep 17 00:00:00 2001 From: Andrii Dovgaliuk Date: Wed, 24 Oct 2012 09:47:19 -0400 Subject: fix a typo in comments to ActiveRecord::Associations::Association.stale_state --- activerecord/lib/active_record/associations/association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index ba75c8be41..2a5f727728 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -223,7 +223,7 @@ module ActiveRecord end # This should be implemented to return the values of the relevant key(s) on the owner, - # so that when state_state is different from the value stored on the last find_target, + # so that when stale_state is different from the value stored on the last find_target, # the target is stale. # # This is only relevant to certain associations, which is why it returns nil by default. -- cgit v1.2.3 From 7a36dc736f6094322dc8bbcf3c98c1cf185d78af Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 26 Oct 2012 13:40:24 -0500 Subject: update AR::ImmutableRelation documentation [ci skip] --- activerecord/lib/active_record/errors.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index 0637dd58b6..f039c23675 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -193,6 +193,20 @@ module ActiveRecord end + # Raised when a relation cannot be mutated because it's already loaded. + # + # class Task < ActiveRecord::Base + # end + # + # relation = Task.all + # relation.loaded? # => true + # + # # where! will try to mutate the relation, but this will fails because it's loaded + # relation.where!(title: 'TODO') + # # => ActiveRecord::ImmutableRelation + # + # relation.limit!(5) + # # => ActiveRecord::ImmutableRelation class ImmutableRelation < ActiveRecordError end -- cgit v1.2.3 From 2c4faaaedd36fd7c55bef516c71d3dd5f46a6164 Mon Sep 17 00:00:00 2001 From: kennyj Date: Fri, 2 Nov 2012 01:34:29 +0900 Subject: This is comment for singular association. --- activerecord/lib/active_record/associations/singular_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/singular_association.rb b/activerecord/lib/active_record/associations/singular_association.rb index 32f4557c28..10238555f0 100644 --- a/activerecord/lib/active_record/associations/singular_association.rb +++ b/activerecord/lib/active_record/associations/singular_association.rb @@ -12,7 +12,7 @@ module ActiveRecord target end - # Implements the writer method, e.g. foo.items= for Foo.has_many :items + # Implements the writer method, e.g. foo.bar= for Foo.belongs_to :bar def writer(record) replace(record) end -- cgit v1.2.3 From 1c3bdfcda4ddb23b69bf00e13cc6120b4ff428dc Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 3 Nov 2012 01:27:14 +0530 Subject: Revert "Updated activerecord test comments to new hash syntax" This reverts commit 3b89052014c2bf3b8fbbcfb93f657a17dd7e7ca3. Reason: changes made to a test, albeit in commented lines - non-uniform change. [ci skip] --- activerecord/test/cases/base_test.rb | 4 ++-- .../test/cases/validations/i18n_generate_message_validation_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 65e8ccdbc8..0f859bf452 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -838,7 +838,7 @@ class BasicsTest < ActiveRecord::TestCase g = Geometric.new( :a_point => '(5.0, 6.1)', - #a_line: '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql + #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql :a_line_segment => '(2.0, 3), (5.5, 7.0)', :a_box => '2.0, 3, 5.5, 7.0', :a_path => '[(2.0, 3), (5.5, 7.0), (8.5, 11.0)]', # [ ] is an open path @@ -867,7 +867,7 @@ class BasicsTest < ActiveRecord::TestCase g = Geometric.new( :a_point => '5.0, 6.1', - #a_line: '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql + #:a_line => '((2.0, 3), (5.5, 7.0))' # line type is currently unsupported in postgresql :a_line_segment => '((2.0, 3), (5.5, 7.0))', :a_box => '(2.0, 3), (5.5, 7.0)', :a_path => '((2.0, 3), (5.5, 7.0), (8.5, 11.0))', # ( ) is a closed path diff --git a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb index 5af9733a68..174d96aa4e 100644 --- a/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_generate_message_validation_test.rb @@ -18,7 +18,7 @@ class I18nGenerateMessageValidationTest < ActiveRecord::TestCase I18n.backend = @old_backend end - # validates_associated: generate_message(attr_name, :invalid, message: custom_message, value: value) + # validates_associated: generate_message(attr_name, :invalid, :message => custom_message, :value => value) def test_generate_message_invalid_with_default_message assert_equal 'is invalid', @topic.errors.generate_message(:title, :invalid, :value => 'title') end @@ -27,7 +27,7 @@ class I18nGenerateMessageValidationTest < ActiveRecord::TestCase assert_equal 'custom message title', @topic.errors.generate_message(:title, :invalid, :message => 'custom message %{value}', :value => 'title') end - # validates_uniqueness_of: generate_message(attr_name, :taken, message: custom_message) + # validates_uniqueness_of: generate_message(attr_name, :taken, :message => custom_message) def test_generate_message_taken_with_default_message assert_equal "has already been taken", @topic.errors.generate_message(:title, :taken, :value => 'title') end -- cgit v1.2.3 From ee917493e451e552fef18367f8bcba2f36080685 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 3 Nov 2012 01:41:44 +0530 Subject: copy edits [ci skip] --- activerecord/lib/active_record/errors.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb index f039c23675..04c0fbfe70 100644 --- a/activerecord/lib/active_record/errors.rb +++ b/activerecord/lib/active_record/errors.rb @@ -201,12 +201,9 @@ module ActiveRecord # relation = Task.all # relation.loaded? # => true # - # # where! will try to mutate the relation, but this will fails because it's loaded - # relation.where!(title: 'TODO') - # # => ActiveRecord::ImmutableRelation - # - # relation.limit!(5) - # # => ActiveRecord::ImmutableRelation + # # Methods which try to mutate a loaded relation fail. + # relation.where!(title: 'TODO') # => ActiveRecord::ImmutableRelation + # relation.limit!(5) # => ActiveRecord::ImmutableRelation class ImmutableRelation < ActiveRecordError end -- cgit v1.2.3