Permalink
Browse files

Extracting relation creation to a method

  • Loading branch information...
1 parent 1fa059c commit 3d3ba34f67e663f51b3aae588ee1db5d1d781373 @reu reu committed Jun 12, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/base.rb
@@ -661,7 +661,7 @@ def set_table_name(value = nil, &block)
define_attr_method :table_name, value, &block
@arel_table = nil
- @relation = Relation.new(self, arel_table)
+ @relation = create_relation
end
alias :table_name= :set_table_name
@@ -974,7 +974,7 @@ def instantiate(record)
private
def relation #:nodoc:
- @relation ||= Relation.new(self, arel_table)
+ @relation ||= create_relation
if finder_needs_type_condition?
@relation.where(type_condition).create_with(inheritance_column.to_sym => sti_name)
@@ -983,6 +983,10 @@ def relation #:nodoc:
end
end
+ def create_relation
+ Relation.new(self, arel_table)
+ end
+
def find_sti_class(type_name)
if type_name.blank? || !columns_hash.include?(inheritance_column)
self

0 comments on commit 3d3ba34

Please sign in to comment.