Searchlogic plugin: ActiveRecord search on Steroids

Searchlogic is everything you would ever wish from AR search and you could not find.

The brilliant ideea is that the search itself is seen as an object, so you can add/remove conditions very easy.

search = User.new_search
search.conditions.hour_of_created_at = 5

Another really useful thing is the support for relationships:

search.conditions.images.author.name = "Name"

Other good features are group support

  search = User.new_search
  search.id_gt = 2
  group1 = search.conditions.group
  group1.first_name_like = "Ben"
  group2 = search.conditions.group
  group2.last_name_like = "Johnson"
  group21 = group2.group
  group21.email_ends_with = "binarylogic.com"

pagination support

search.per_page = 20
search.page = 3

and startst_with/ends_with/contains/sounds_like etc. column conditions:

search.conditions.email_ends_with = "binarylogic.com"
search.conditions.created_after = Time.now
group2.last_name_like = "Johnson"

A feature that may be used on ‘fuzzy’ searches is the support for OR between conditions (instead of default AND)

@search.conditions.any = true

It is now available as a gem so you should only

sudo gem install searchlogic

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: