<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -2027,7 +2027,7 @@ module ActiveRecord #:nodoc:
         #     default_scope :find =&gt; { :order =&gt; 'last_name, first_name' }
         #   end
         def default_scope(options = {})
-          self.default_scoping &lt;&lt; { :find =&gt; options, :create =&gt; options.is_a?(Hash) ?  options[:conditions] : {} }
+          self.default_scoping &lt;&lt; { :find =&gt; options, :create =&gt; (options.is_a?(Hash) &amp;&amp; options.has_key?(:conditions)) ? options[:conditions] : {} }
         end
 
         # Test whether the given method and optional key are scoped.</diff>
      <filename>activerecord/lib/active_record/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -532,7 +532,7 @@ class DefaultScopingTest &lt; ActiveRecord::TestCase
   end
 
   def test_default_scoping_with_threads
-    scope = [{:create=&gt;nil, :find=&gt;{:order=&gt;&quot;salary DESC&quot;}}]
+    scope = [{ :create =&gt; {}, :find =&gt; { :order =&gt; 'salary DESC' } }]
 
     2.times do
       Thread.new { assert_equal scope, DeveloperOrderedBySalary.send(:scoped_methods) }.join
@@ -540,14 +540,14 @@ class DefaultScopingTest &lt; ActiveRecord::TestCase
   end
 
   def test_default_scoping_with_inheritance
-    scope = [{:create=&gt;nil, :find=&gt;{:order=&gt;&quot;salary DESC&quot;}}]
+    scope = [{ :create =&gt; {}, :find =&gt; { :order =&gt; 'salary DESC' } }]
 
     # Inherit a class having a default scope and define a new default scope
     klass = Class.new(DeveloperOrderedBySalary)
     klass.send :default_scope, {}
 
     # Scopes added on children should append to parent scope
-    expected_klass_scope = [{:create=&gt;nil, :find=&gt;{:order=&gt;&quot;salary DESC&quot;}}, {:create=&gt;nil, :find=&gt;{}}]
+    expected_klass_scope = [{ :create =&gt; {}, :find =&gt; { :order =&gt; 'salary DESC' }}, { :create =&gt; {}, :find =&gt; {} }]
     assert_equal expected_klass_scope, klass.send(:scoped_methods)
     
     # Parent should still have the original scope
@@ -568,6 +568,12 @@ class DefaultScopingTest &lt; ActiveRecord::TestCase
     assert_equal expected, received
   end
 
+  def test_named_scope
+    expected = Developer.find(:all, :order =&gt; 'name DESC').collect { |dev| dev.salary }
+    received = DeveloperOrderedBySalary.by_name.find(:all).collect { |dev| dev.salary }
+    assert_equal expected, received
+  end
+
   def test_nested_exclusive_scope
     expected = Developer.find(:all, :limit =&gt; 100).collect { |dev| dev.salary }
     received = DeveloperOrderedBySalary.with_exclusive_scope(:find =&gt; { :limit =&gt; 100 }) do</diff>
      <filename>activerecord/test/cases/method_scoping_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -79,13 +79,13 @@ class DeveloperWithBeforeDestroyRaise &lt; ActiveRecord::Base
 end
 
 class DeveloperOrderedBySalary &lt; ActiveRecord::Base
-    self.table_name = 'developers'
-    default_scope :order =&gt; &quot;salary DESC&quot;
+  self.table_name = 'developers'
+  default_scope :order =&gt; 'salary DESC'
+  named_scope :by_name, :order =&gt; 'name DESC'
 
-    def self.all_ordered_by_name
-      with_scope(:find =&gt; { :order =&gt; &quot;name DESC&quot; }) do
-        find(:all)
-      end
+  def self.all_ordered_by_name
+    with_scope(:find =&gt; { :order =&gt; 'name DESC' }) do
+      find(:all)
     end
-
+  end
 end</diff>
      <filename>activerecord/test/models/developer.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3a33ee28e9babc5a1a78079f5ca50ea6249f2643</id>
    </parent>
  </parents>
  <author>
    <name>Tom Stuart</name>
    <email>tom@experthuman.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/32cb2345a54b9ab38461b2d4bb0dbd1706f2800e</url>
  <id>32cb2345a54b9ab38461b2d4bb0dbd1706f2800e</id>
  <committed-date>2008-11-17T13:00:14-08:00</committed-date>
  <authored-date>2008-11-17T12:10:59-08:00</authored-date>
  <message>Fix default_scope to work in combination with named scopes

Signed-off-by: David Heinemeier Hansson &lt;david@loudthinking.com&gt;</message>
  <tree>9da1d7efd04f2f589c777699e2d3c6274820d4be</tree>
  <committer>
    <name>David Heinemeier Hansson</name>
    <email>david@loudthinking.com</email>
  </committer>
</commit>
