robert bradford
2006-Jul-13 20:05 UTC
[Rails] best practice on making a searchable/filterable list?
Hi, I have many pages that list information (modified from the scaffolding). I would like to include a box at the top of these pages that has some search criteria with drop downs, date ranges, etc. When the user submits, the controller then adds appropriate conditions to the find method, and the matching records are displayed with the search form maintaining the users selections. I have been messing around with something like the following: <h2>Search Criteria</h2> <%= start_form_tag :action => "list" %> <label>Status:</label> <%= select "search", "status", @statuses, :prompt => ''-All-'' %><br/> <label>Assignee:</label> <%= select "search", "assignee", @assignees.collect { |u| [u.name, u.id] }, :prompt => ''-All-'' %><br/> #... <%= submit_tag "find" %> <%= end_form_tag %> Am I on the right track, or does anyone have a good way of doing this? -- Posted via http://www.ruby-forum.com/.