From 72632d8fa950cc036a3afa52ad9cbd8d654c2d64 Mon Sep 17 00:00:00 2001 From: Sam Granieri Date: Mon, 9 Mar 2009 11:43:48 -0500 Subject: [PATCH] Fix for declaring a different scope for finding, and one for creation --- activerecord/lib/active_record/base.rb | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index edc1459..bdf6de5 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2168,7 +2168,18 @@ module ActiveRecord #:nodoc: # default_scope :order => 'last_name, first_name' # end def default_scope(options = {}) - self.default_scoping << { :find => options, :create => (options.is_a?(Hash) && options.has_key?(:conditions)) ? options[:conditions] : {} } + thescope={} + thescope[:find]=options + if options.is_a?(Hash) && options.has_key?(:conditions) + if options.has_key?(:create) + thescope[:create]=options[:create] + else + thescope[:create]=options[:conditions] + end + else + thescope[:create]={} + end + self.default_scoping << thescope end # Test whether the given method and optional key are scoped. -- 1.6.2