From 196f92f366cdf86aab3c62c3a08bbf10f9bc413e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 27 Jun 2011 20:44:39 -0700 Subject: [PATCH] remove the check for needs_type_condition? because ensure_proper_type will pick up the type column --- activerecord/lib/active_record/base.rb | 5 +++-- activerecord/lib/active_record/named_scope.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1f3b74bc96..055386804a 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1916,8 +1916,9 @@ MSG # do Reply.new without having to set Reply[Reply.inheritance_column] = "Reply" yourself. # No such attribute would be set for objects of the Message class in that example. def ensure_proper_type - unless self.class.descends_from_active_record? - write_attribute(self.class.inheritance_column, self.class.sti_name) + klass = self.class + if klass.finder_needs_type_condition? + write_attribute(klass.inheritance_column, klass.sti_name) end end diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 252f116a39..37c67fe766 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -48,7 +48,7 @@ module ActiveRecord current_scope.scope_for_create else # Return an empty hash in the simple case - return {} unless finder_needs_type_condition? || default_scopes.any? + return {} unless default_scopes.any? scope = relation.clone scope.default_scoped = true