
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
-
Ben Johnson March 30th, 2009 @ 11:49 AM
- State changed from new to resolved
yes:
user.select :first_name ["Joe", "Bob"], :include_blank => "Any"
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.
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.