diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-16 23:11:35 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-16 23:11:35 +0530 |
commit | 3968825f5ff6a75cb83400716d56ec10f261e41a (patch) | |
tree | 2a595291556ae52b920036e596fd2b7f257e4ab2 /activerecord/lib/active_record/base.rb | |
parent | cfdfd899262c79c37ac89e030f4d90c8f9868b50 (diff) | |
download | rails-3968825f5ff6a75cb83400716d56ec10f261e41a.tar.gz rails-3968825f5ff6a75cb83400716d56ec10f261e41a.tar.bz2 rails-3968825f5ff6a75cb83400716d56ec10f261e41a.zip |
Make sure Model#active_relation always adds STI conditions if needed
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5bd24ac3eb..d0db9fadcd 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -872,7 +872,6 @@ module ActiveRecord #:nodoc: relation = active_relation relation = relation.where(conditions) if conditions - relation = relation.where(type_condition) if finder_needs_type_condition? relation = relation.limit(options[:limit]) if options[:limit].present? relation = relation.order(options[:order]) if options[:order].present? @@ -1389,7 +1388,7 @@ module ActiveRecord #:nodoc: def reset_column_information undefine_attribute_methods @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @inheritance_column = nil - @active_relation = @arel_engine = nil + @arel_engine = @active_relation = @arel_engine = nil end def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc: @@ -1504,6 +1503,7 @@ module ActiveRecord #:nodoc: def active_relation @active_relation ||= Relation.new(self, arel_table) + finder_needs_type_condition? ? @active_relation.where(type_condition) : @active_relation end def arel_table(table_name_alias = nil) @@ -1564,7 +1564,6 @@ module ActiveRecord #:nodoc: def construct_finder_arel(options = {}, scope = nil) relation = active_relation.apply_finder_options(options) - relation = relation.where(type_condition) if finder_needs_type_condition? relation = scope.merge(relation) if scope relation end |