To get multiple check_box values in controller

Hi
I have

<% for language in @languages %>
<%= language.language %> <%=
check_box(“user”,“language_id”,{},checked_value = “1”, unchecked_value =
“0”) %>
<% end %>

 What I am trying to do is if a user check more than one language

say English and Spanish I shud get bothe these values to controller
and there I can craete the user and save the languages there.Please tell
me how can I do this I tried like above but always getting
params[:user][:language_id] as 0

TABLES
Languages table contains id, language
Users table contains id, name, language_id
MODEL
Relation ships mentioned
class Language < ActiveRecord::Base
has_many :users
end

class User < ActiveRecord::Base
belongs_to :language
end

Thanks in advance
Sijo

Hi
Thanks for the reply I tried like
<% for language in @languages %>
<%= language.language %> <%=
check_box_tag(“user[#{language.id}][]”,"#{language.id}") %>
<% end %>
And the source obtained is
English
Spanish
Persian
Is this correct?Then how can I access this in controller and to know
which one is clicked and which one not?

Sijo

On Sep 17, 6:44 am, Sijo Kg [email protected] wrote:

Hi
I have

<% for language in @languages %>
<%= language.language %> <%=
check_box(“user”,“language_id”,{},checked_value = “1”, unchecked_value =
“0”) %>
<% end %>

You’ve got to use check_box_tag and not check_box, set the parameter
name to user[language_id][] and give each checkbox a different value
(ie the id of the corresponding language.

Fred

Is there a way to have this working while being able to use labels, and
being valid HTML? Ie, unique IDs for the inputs?

no - you want the output to be

and then params[:user][:language_id] will be an array

Fred

On 17 Sep 2008, at 10:41, Sijo Kg wrote:

/>
Spanish
Persian

Is this correct?Then how can I access this in controller and to
know
which one is clicked and which one not?

no - you want the output to be

and then params[:user][:language_id] will be an array

Fred