Skip to content

Scoped search comparison operators

August 11, 2011

Scoped search uses ActiveRecord infrastructure to learn about the database schema. The auto-completer uses the column type to suggest the optional operators. Textual fields will have ‘~’ (like), ‘!~’ (unlike), ‘=’ and ‘!=’. Numerical fields will have ‘>’, ‘<‘, ‘>=’, ‘<=’, ‘=’ and ‘!=’. Usualy this is something a developer using scoped search doesn’t need to worry about, scope search find the database column type and suggest the relevant operators, however there could be some cases where a developer will want to limit the operators set for a particular search term.

The syntax to control the auto-completer suggested operator list is to add :operators => { ‘=’, ‘!=’ } to the scoped_search command.



From → Design, Developers

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: