#74 ✓resolved
Tee Parham

Ignore certain select items in conditions

Reported by Tee Parham | March 27th, 2009 @ 05:55 PM

I want to ignore a certain value from a select list in my conditions. How do I specify that?

Here's an example where I have a select list of 'Any', 'Joe', and 'Bob'. If 'Any' is selected, I want to exclude that condition and thus find all users. Is there a better way than manually checking for the 'Any' value and then deleting that condition in the controller? If not, what is the preferred way to remove a condition?

  # app/views/users/index.html.haml
  - form_for @search do |f|
    - f.fields_for @search.conditions do |users|
      = users.select :first_name, ['Any','Joe','Bob']
    = f.submit "Search"

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