method on activerecord::relation
<p>So i do have a User model, on which i need <code>by_posts</code> method. <code>by_post</code> is intended to be executed on already browsed users, eg on </p>

<pre><code>users.where(name: "Jack")
</code></pre>

<p>I imagine this method as:</p>

<pre><code>self.by_post(condition)
    return self if condition.blank?
    ##something
end
</code></pre>

<p>But right know when i return self like this, it returns a class, not a relation. So when i call this method on object such as:</p>

<pre><code>    (byebug) users
    []
    (byebug) users.class
    ActiveRecord::Relation
</code></pre>

<p>what i get back after</p>

<pre><code>users.by_post(nil)
</code></pre>

<p>is:</p>

<pre><code>(byebug) users
User(id: integer, , username: string, email: string, created_at: datetime, updated_at: datetime etc
</code></pre>

<p>How can i make this method return the exact same object it begun with?</p>