Thanks. It's now working. Just to clarify for someone else as I did it 
wrong the first time, the class method goes in the Controller not in the 
Model.

On Tuesday, March 24, 2015 at 4:54:53 AM UTC-4, Sergio Cambra wrote:
>
>  El Domingo, 22 de marzo de 2015 12:32:00 Jeff Surrett escribió:
>
> > I am trying to use regular search and field_search at the same time. I
>
> > would like to be able to search by the name of a related field using the
>
> > regular search while using the select method from the field_search. The
>
> > problem is that if I set the search_sql like:
>
> > 
>
> > config.columns[:employee].search_sql = ['employees.last_name',
>
> > 'employees.first_name']
>
> > 
>
> > the regular search will work but the field search will not. The field
>
> > search will use the dropdown with the employee names but will then search
>
> > the name fields for the id number, finding no matches.
>
> > 
>
> > Is there a simple way of setting the search_sql for just the regular 
> search
>
> > and have the field_search still search based on the related id?
>
>  
>
> You can create a class method to return sql for employee column, which 
> will be used for field search. Something like:
>
>  
>
> def self.condition_for_employee_column(column, value, like_pattern)
>
> ['employee_id IN (?)', Array(value)]
>
> end
>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.

Reply via email to