#51 ✓resolved
Marcel Ruegenberg

Multiple conditions on single attribute?

Reported by Marcel Ruegenberg | February 11th, 2009 @ 07:10 AM

Is it possible to have multiple conditions on a single attribute?

search = User.new_search
search.conditions.name_like = "Foo"
search.conditions.or_name_like = "Bar"

Currently, this only uses one of the two conditions, it generates something like

... WHERE name LIKE "Foo"
instead of joining the two conditions with OR.

My current workaround is to use groups:

search = User.new_search
search.conditions.group do |group|
  group.or_group do |group|
    group.name_like = "Foo"
  group.or_group do |group|
    group.name_like = "Bar"

This works, but is kind of verbose...

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket