title: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "clients"
body: <p>I got the following error:</p>
  
  <p>PG::UndefinedTable: ERROR:  missing FROM-clause entry for table "clients".</p>
  
  <p>This occurs when I try to execute the following query:</p>
  
  <pre><code>SELECT  "folders".* FROM "folders" WHERE (clients.name ilike '%aleena%')  ORDER BY clients.name LIMIT 10):
  </code></pre>
  
  <p>The following code is used for select: </p>
  
  <pre><code>  def search_folders
      Folder.where('clients.name ilike :search', search: "%#{@params[:s]}%")
            .references(:clients)
            .order('clients.name')
            .limit(@params[:per] || 10)
    end
  </code></pre>