What''s the paradigm for providing a set of filters for search results? Here''s my example: I have a list of projects, and projects can be filtered by manager, status (open, closed, in progress), start date, etc. The filter settings are stored in the database using the preferences plugin, which works very nicely. However, my code is ugly, and I can''t detect when a filter has be unset, which makes me think there is a better way. ProjectsController: # the if statement always returns true even if show_closed_projects is unchecked def index @projects = Projects.all if defined? params[:show_closed_projects] && params[:show_closed_projects] == ''on'' current_user.write_preference(:show_closed_projects, true) @projects = @projects.closed # this is a named scope else current_user.wrirte_preference(:show_closed_projects, false) end end views/projects/index.html.erb # this works -- if the preference is set, the checkbox is checked, otherwise, it''s not checked. <div id="project-filters" style="display:none" class="options"> <form action="/company/6/projects"> <fieldset> <legend>project filter options</legend> <table class="vertical-columns"> <tr> <th colspan=2> <input type="checkbox" name="show_closed_projects" <%=h current_user.prefers_show_closed_projects ? "checked" : "" %> > Show closed projects? </th> </tr> </table> </fieldset> <p class="button-container"> <%= submit_tag "save filters" %> <%= link_to "cancel" %> </p> </form> </div> ...projects listed here... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.