Selecting rows with checkboxes and process them

Hi, i am wondering how i could do the following:

I want to display all records of a table with a checkbox in front of it
and after i checked some of them i want to submit this form and the
controller has to process the selected records. (changing the value of a
status field)

if someone could give me some pointers or maybe a code example, i would
be very gratefull!

thanks

remco

I’m pressed for time thsi morning. If you own a copy of
AgileWebDevelopment then look up [] and it will give you the answer. If
you don’t own the book, I’d suggest you buy one if at all possible. It
will save you tens of hours of misery.

If that doesn’t work try a google search including [] as this is what
you add to the model name to get what you want.

hi, thanks for the answer
I searched the book, but all i can find is that [] is the declaration of
an array and that i already knew :o)

searching “[]” with google is not possible

[email protected] wrote:

I’m pressed for time thsi morning. If you own a copy of
AgileWebDevelopment then look up [] and it will give you the answer. If
you don’t own the book, I’d suggest you buy one if at all possible. It
will save you tens of hours of misery.

If that doesn’t work try a google search including [] as this is what
you add to the model name to get what you want.

hey, uh well just customize the list.rhtml view so that it loops through
each record and writes out a checkbox for each one in the correct
location with a unique name, something like “checkbox_1” where the 1 is
the id of the current record. Then wrap the list in a form pointing to
an action called “list_update” or something. Then in the action, loop
through all the items in param saying:

param.each do |key,value|
if key =~ /^checkbox_([0-9]+)$/
@record.find($1)
@record.status = “new status”
@record.save
end
end

Remco Hh wrote:

thanks

remco

Jeremy W.
Serval Systems Ltd.

www.servalsystems.co.uk http://www.servalsystems.co.uk
Tel: 01342 331940
Fax: 01342 331950

Thank you Jeremy,
I get it :0)
i am going to trie this

Jeremy W. wrote:

hey, uh well just customize the list.rhtml view so that it loops through
each record and writes out a checkbox for each one in the correct
location with a unique name, something like “checkbox_1” where the 1 is
the id of the current record. Then wrap the list in a form pointing to
an action called “list_update” or something. Then in the action, loop
through all the items in param saying:

param.each do |key,value|
if key =~ /^checkbox_([0-9]+)$/
@record.find($1)
@record.status = “new status”
@record.save
end
end

Remco Hh wrote:

thanks

remco

Jeremy W.
Serval Systems Ltd.

www.servalsystems.co.uk http://www.servalsystems.co.uk
Tel: 01342 331940
Fax: 01342 331950