Refactor ruby code based on the admin present or not
<p>I want to refactor this code:</p>

<pre><code>def self.find_posts(page, per_page, author_id, user)
  if user.admin?
    paginate(page: page, per_page: per_page)  #fetches on the basis of per_page
  else
    paginate(page: page, per_page: per_page).where(author: author_id) #Based on author_id
  end
end
</code></pre>

<p><code>Post.paginate(page: page, per_page: per_page)</code> is repeated two times so I wanted to remove it.</p>

<p>Here is what I tried:</p>

<pre><code>def self.find_posts(page, per_page, author_id, user)
  paginate(page: page, per_page: per_page)  #fetches the no of per_page
  if user.admin?
    #not getting what should I write here
  else
    where(author: author_id) #Based on author_id
  end
end
</code></pre>

<p>This code also doesn't work which I know that <code>paginate</code> is not the last sentence. I could use <code>return</code> there but somehow I'm not understanding how to do it.</p>