Skip to content

Commit

Permalink
Improve the error message for class mismatch on Relation#merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Jan 16, 2010
1 parent 7f8d4d3 commit 468cfce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion activerecord/lib/active_record/relation/spawn_methods.rb
Expand Up @@ -15,7 +15,9 @@ def spawn(arel_table = self.table)
end

def merge(r)
raise ArgumentError, "Cannot merge a #{r.klass.name} relation with #{@klass.name} relation" if r.klass != @klass
if r.klass != @klass
raise ArgumentError, "Cannot merge a #{r.klass.name}(##{r.klass.object_id}) relation with #{@klass.name}(##{@klass.object_id}) relation"
end

merged_relation = spawn.eager_load(r.eager_load_values).preload(r.preload_values).includes(r.includes_values)

Expand Down

0 comments on commit 468cfce

Please sign in to comment.