Forum: Ruby on Rails filter a list

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A2bfa8f483e1aa2c7e4188d1d30af778?d=identicon&s=25 Santiago Hirschfeld (Guest)
on 2006-02-16 18:26
(Received via mailing list)
I'd like to add some filter choices to display a list of items. These
items has some boolean fields for example, and would like to have a
checkbox at the top of the window to let me select how to filter the
list.

here's what i put in my controller

if @params[:filter].nil?
  @params[:filter] = { 'sent' => "1"}
end

... generate the corresponding @items array ..

here's what i did in my view

<%= form_tag :action => 'list_items' %>
    <%= check_box 'filter','sent' %>
    <%= submit_tag 'Filter' %>
<%= end_form_tag %>

<table> ..... </table>

inspecting the @params value, it seems to has a filter[:sent] key,
with the correct value (1 if checked) but the check button is always
unchecked when the page is generated.

Am i so wrong doing this? is there a better way?
A2bfa8f483e1aa2c7e4188d1d30af778?d=identicon&s=25 Santiago Hirschfeld (Guest)
on 2006-02-17 05:10
(Received via mailing list)
anyone? please
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2006-02-17 07:25
(Received via mailing list)
Look at Enumerable.grep

--
-- Tom Mornini
A2bfa8f483e1aa2c7e4188d1d30af778?d=identicon&s=25 Santiago Hirschfeld (Guest)
on 2006-02-17 15:28
(Received via mailing list)
Thanks, I know i wasn't clear enough, i'm not a native english
speaker. But my problem is not how to filter the list, my problem is
with the checkbox being always unchecked and not mantaining the state
of selected, don't know if what i'm doing is right.
Thanks anyway.

Can someone give me a hint? please?


2006/2/17, Tom Mornini <tmornini@infomania.com>:
4f86dba83a7b1b127263bb3fdd0b09e7?d=identicon&s=25 Ammon Christiansen (ammonc)
on 2006-02-18 02:17
(Received via mailing list)
Save the state of the checkbox when submitted in the session and then
use the value of the session variable in the tag's definition to
maintain its value.
A2bfa8f483e1aa2c7e4188d1d30af778?d=identicon&s=25 Santiago Hirschfeld (Guest)
on 2006-02-18 06:19
(Received via mailing list)
thanks, that did it

2006/2/17, Ammon Christiansen <ammon.christiansen@gmail.com>:
This topic is locked and can not be replied to.