#102 ✓resolved
atmorell

Join scopes with OR

Reported by atmorell | July 20th, 2009 @ 10:12 AM

Hey Ben,

I have a form where the user can select price ranges:

Form:

  • form_for @search do |f| =f.text_field :title_like %h2 Prices =f.check_box :cheap_price =f.check_box :budget_price =f.check_box :normal_price =f.submit

Model:

Painting.named_scope :cheap_price, :conditions => {:price => 1..500}
Painting.named_scope :budget_price, :conditions => {:price => 500..1000}
Painting.named_scope :normal_price, :conditions => {:price => 1000..2000}

My problem is that the scopes is joined with AND. I would like to join with OR, so that the visitor can e.g see cheap_price and budget_price at the same time etc.

Any suggestions?

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

Pages