I the following models
class Company < ActiveRecord::Base
attr_accessible :name, address, ........
has_many :employees
end
class Employee < ActiveRecord::Base
attr_accessible :firstname, :lastname, :company_id, .............
belongs_to :company
end
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
Employee.where("firstname like ? or lastname like ? or company.name like ?", q,q,q)
What is the best way to achieve this with rails?