I have a doubt. I’m using rails 3. And i want to filter my model. Supose, this
class Company
attr_accesible :name, :description
end
In a sql server stored procedure i’d do something like this
select * from Company where (@company_name is null or name like @company_name) and (@company_description is null or description like @company_description) and (@ids is null or id in @ids)
The code above is an example. Is for filter propouses. Which is the proper way to build a query like that?
Thanks in advance
Hope be clear.
Ok, as I understood you have in your view form for @company with name\description\ids fields.
Then in your controller you can do the search like that: