0

I want to do something similar to : @search(some_condition or some_other_condition)

this is how the internet says to use OR http://www.binarylogic.com/2009/08/26/using-searchlogic-to-combine-named-scopes-with-or/

unfortunately it only uses the same value for two fields.

So.. IS there a way to do @search.(some_field == value OR other_field == other_value) ?

NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352

1 Answers1

-1

Don't resort to searchlogic for the or part, just use ruby.

result = @search.first_name_like('The') || @search.last_name_like('LindyHop')

Is there a reason that I'm not following as to why you can't do it like this?

theIV
  • 25,434
  • 5
  • 54
  • 58
  • yeah, because I'me using search logic for pagination as well (w/ will_paginate). example: @people = @search.paginate(:page => params[:page], :per_page => 15) – NullVoxPopuli Aug 01 '11 at 14:08
  • Could you not paginate over `result` in my suggested answer? I don't remember how will_paginate works exactly. – theIV Aug 01 '11 at 16:08
  • you updated your answer or it looks different from how I last saw it. But doing || with the SearchLogic object should work. – NullVoxPopuli Aug 01 '11 at 16:54