Skip to content
Browse files

remove the check for needs_type_condition? because ensure_proper_type…

… will pick up the type column
  • Loading branch information...
1 parent 992b3b5 commit 196f92f366cdf86aab3c62c3a08bbf10f9bc413e @tenderlove tenderlove committed Jun 27, 2011
Showing with 4 additions and 3 deletions.
  1. +3 −2 activerecord/lib/active_record/base.rb
  2. +1 −1 activerecord/lib/active_record/named_scope.rb
View
5 activerecord/lib/active_record/base.rb
@@ -1916,8 +1916,9 @@ def set_serialized_attributes
# do Reply.new without having to set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> 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
View
2 activerecord/lib/active_record/named_scope.rb
@@ -48,7 +48,7 @@ def scope_attributes # :nodoc:
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

0 comments on commit 196f92f

Please sign in to comment.
Something went wrong with that request. Please try again.