# "clone" at active\_record relation

**URL:** <https://www.ruby-forum.com/t/clone-at-active-record-relation/194538>\
**Category:** Rails\
**Created:** [September 6, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/clone-at-active-record-relation/194538 "2010-09-06T20:42:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [September 6, 2010, 8:42pm UTC](https://www.ruby-forum.com/t/clone-at-active-record-relation/194538/1 "2010-09-06T20:42:10Z")

</div>

inside Rails source, at

> <https://github.com/rails/rails/blob/main/activerecord/lib/active_record/relation/query_methods.rb>

I found a lot of calls to:

```
relation = clone

```

I can understand where id the “relation” call, but… how about “clone”  
?  
Perhaps “clone” comes from Ruby1.9-Kernel, but I am not sure.  
And github color it in blue, like a class…weird…

```
def where(opts, *rest)
  relation = clone

  if opts.present? && value = build_where(opts, rest)
    relation.where_values += Array.wrap(value)
  end

  relation
end

```

Can somebody explain this “clone” ? Where it come from ?  
Thanks
