title: Ruby on Rails / SQL Query with
body: <p>I the following models</p>
  
  <pre><code>class Company &lt; ActiveRecord::Base
      attr_accessible :name, address, ........
  
       has_many :employees
  end
  
  class Employee &lt; ActiveRecord::Base
      attr_accessible :firstname, :lastname, :company_id, .............
  
      belongs_to :company
  
  end
  </code></pre>
  
  <p>I have a string q and would like to select all the employees whos firstname lastname or company.name are like q, something along the line of this query non working query</p>
  
  <pre><code>Employee.where("firstname like ? or lastname like ? or company.name like ?", q,q,q)
  </code></pre>
  
  <p>What is the best way to achieve this with rails?</p>