Collecting checked checkboxes from table

Hi, I'm new to RoR, so this is a beginners question, I know. (Bought
Agile 2 in pdf, Recipes and Ruby For Rails, stillstudying) So please
forgive me this very simpel request.

I have a list with rubrics, each with a checkbox. The user ticks a few
checkboxes, and presses the submitbutton. I'd like to get those rubrics
that are checked, and store their id in a db.

I have this for the list

<% form_for :rubric, :url => {:action => :checked} do |form| %> <%
@rubrics.each do |@rubric| %>
          <%= @rubric.headdrubric %> ===>
          <%= @rubric.partrubric %>
          <%= check_box_tag("rubric[]", @rubric.id)%>
            <br />
    <% end %>
         <%= submit_tag "Add", :class => "submit" %>
<% end %>

But after searching this forum, and my books, I am very unsure on how
to collect the id's of the chosen rubrics. I think I stumbled on 10
snippets, thought each time tthis may be it, tried it, always failed.
Again this is very basic, I suppose, but I really would appriate any
help or suggestion. Thanks in advance.

Rudy wrote:

Hi, I'm new to RoR, so this is a beginners question, I know. (Bought
Agile 2 in pdf, Recipes and Ruby For Rails, stillstudying) So please
forgive me this very simpel request.

I have a list with rubrics, each with a checkbox. The user ticks a few
checkboxes, and presses the submitbutton. I'd like to get those rubrics
that are checked, and store their id in a db.

I have this for the list

<% form_for :rubric, :url => {:action => :checked} do |form| %> <%
@rubrics.each do |@rubric| %>
          <%= @rubric.headdrubric %> ===>
          <%= @rubric.partrubric %>
          <%= check_box_tag("rubric[]", @rubric.id)%>
            <br />
    <% end %>
         <%= submit_tag "Add", :class => "submit" %>
<% end %>

But after searching this forum, and my books, I am very unsure on how
to collect the id's of the chosen rubrics. I think I stumbled on 10
snippets, thought each time tthis may be it, tried it, always failed.
Again this is very basic, I suppose, but I really would appriate any
help or suggestion. Thanks in advance.

Take a look at the submitted params, they should contain an array
called 'rubric' that will contain all of the checked 'id's.

to see the params, just add this line to the start of your 'checked'
action...

raise 'test'

_Kevin

Thanks for your prompt reply.
All I got was

Parameters: {"commit"=>"Add", "rubric"=>["on"]}

So it looks as if there is no id past on. Or do I misread this message?
I must admit that I'm a bit lost now. It just seems such an obvious
example of an simple programming exercice, but I can't get around it,
and I can't find any example. Any ideas? Thanks for replying.

Right. I am not sure yet how to solve it, but I found the reason why
there was no id. It is so ridiculous, that I deeply feel ashamed, but I
have to wright it down, to prevent some of these good folks here
tostart looking for answer. There was no id, because... it was calling
the one table I copied from another one with all its data in it - and
you guess, NO id-field. The moment I had added that, it appeared in the
search.
That still leaves me hoping for an elegant, simple Ruby-way of
collecting the info... but I will sleep a lot better tonight. Thanks
again.