aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2005-10-09 22:08:16 +0000
committerMarcel Molina <marcel@vernix.org>2005-10-09 22:08:16 +0000
commitf4d1af3085cbe95cd8363fae86696a723122c195 (patch)
tree5fa7e025eac4f1df0738cf803efc02479d4b629b
parent89733eaecffef3c1ad55345677411c872b1c99e4 (diff)
downloadrails-f4d1af3085cbe95cd8363fae86696a723122c195.tar.gz
rails-f4d1af3085cbe95cd8363fae86696a723122c195.tar.bz2
rails-f4d1af3085cbe95cd8363fae86696a723122c195.zip
Fix typo of 'constrains' to 'contraints'. Closes #2069.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2510 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb30
-rw-r--r--activerecord/test/conditions_scoping_test.rb2
3 files changed, 20 insertions, 14 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index a181c89dde..a5cafb69f9 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix typo of 'constrains' to 'contraints'. #2069. [Michael Schuerig <michael@schuerig.de>]
+
* Optimization refactoring for add_limit_offset!. In partial fullfilment of #1236. [skaes@web.de]
* Add ability to get all siblings, including the current child, with acts_as_tree. Recloses #2140. [Michael Schuerig <michael@schuerig.de>]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 95f4364755..022b577704 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -758,18 +758,18 @@ module ActiveRecord #:nodoc:
logger.level = old_logger_level if logger
end
- # Add constrains to all queries to the same model in the given block.
- # Currently supported constrains are <tt>:conditions</tt> and <tt>:joins</tt>
+ # Add constraints to all queries to the same model in the given block.
+ # Currently supported constraints are <tt>:conditions</tt> and <tt>:joins</tt>
#
# Article.constrain(:conditions => "blog_id = 1") do
# Article.find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1
# end
def constrain(options = {}, &block)
begin
- self.scope_constrains = options
+ self.scope_constraints = options
block.call if block_given?
ensure
- self.scope_constrains = nil
+ self.scope_constraints = nil
end
end
@@ -823,13 +823,13 @@ module ActiveRecord #:nodoc:
end
def add_joins!(sql, options)
- join = scope_constrains[:joins] || options[:joins]
+ join = scope_constraints[:joins] || options[:joins]
sql << " #{join} " if join
end
# Adds a sanitized version of +conditions+ to the +sql+ string. Note that it's the passed +sql+ string is changed.
def add_conditions!(sql, conditions)
- condition_segments = [scope_constrains[:conditions]]
+ condition_segments = [scope_constraints[:conditions]]
condition_segments << sanitize_sql(conditions) unless conditions.nil?
condition_segments << type_condition unless descends_from_active_record?
condition_segments.compact!
@@ -918,15 +918,19 @@ module ActiveRecord #:nodoc:
@@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses }
end
- def scope_constrains
- Thread.current[:constrains] ||= {}
- Thread.current[:constrains][self] ||= {}
+ def scope_constraints
+ Thread.current[:constraints] ||= {}
+ Thread.current[:constraints][self] ||= {}
end
-
- def scope_constrains=(value)
- Thread.current[:constrains] ||= {}
- Thread.current[:constrains][self] = value
+ # backwards compatibility
+ alias_method :scope_constrains, :scope_constraints
+
+ def scope_constraints=(value)
+ Thread.current[:constraints] ||= {}
+ Thread.current[:constraints][self] = value
end
+ # backwards compatibility
+ alias_method :scope_constrains=, :scope_constraints=
# Returns the class type of the record using the current module as a prefix. So descendents of
# MyApp::Business::Account would be appear as MyApp::Business::AccountSubclass.
diff --git a/activerecord/test/conditions_scoping_test.rb b/activerecord/test/conditions_scoping_test.rb
index 2f5b28f30f..bf6ddc52d1 100644
--- a/activerecord/test/conditions_scoping_test.rb
+++ b/activerecord/test/conditions_scoping_test.rb
@@ -9,7 +9,7 @@ class ConditionsScopingTest < Test::Unit::TestCase
def test_set_conditions
Developer.constrain(:conditions => 'just a test...') do
- assert_equal 'just a test...', Thread.current[:constrains][Developer][:conditions]
+ assert_equal 'just a test...', Thread.current[:constraints][Developer][:conditions]
end
end