check_box_tag doesn't insert parameter into table

Help! Can anyone see why my code isn't inserting the course_id parameter into my table?

<p>   <%= f.label :course_id %><br />   <t1>     <% for course in current_user.courses.find(:all, :order => 'order_taught') %>

      <%= check_box_tag 'assessment[course_id]', course.id %>       <%=h course.name %>

    <% end %> </p>

Below, you can see the Development Log. It shows that the parameter for "course_id"=>["2"]. But as you can see, the INSERT INTO is inserting a value of 1 for course_id:

Processing AssessmentsController#create (for 127.0.0.1 at 2010-01-16 16:27:24) [POST]   Parameters: {"commit"=>"Create", "authenticity_token"=>"Z8yZOo9q2tz6IC1jmV33qvMO7ULRzcJ8e7q6B0xHP9Y=", "assessment"=>{"name"=>"", "date(1i)"=>"2010", "date(2i)"=>"1", "date (3i)"=>"16", "standard_id"=>"9", "course_id"=>["2"], "strand_id"=>"2"}}   e[4;36;1mUser Load (0.0ms)e[0m e[0;1mSELECT * FROM "users" WHERE ("users"."id" = 12) LIMIT 1e[0m   e[4;35;1mAssessment Create (0.0ms)e[0m e[0mINSERT INTO "assessments" ("name", "created_at", "updated_at", "date", "user_id", "standard_id", "strand_id", "course_id") VALUES('', '2010-01-17 00:27:24', '2010-01-17 00:27:24', '2010-01-16', 12, 9, 2, 1)

Any help would be greatly appreciated!

Not sure where the 1 is coming from, but what you're doing still doesn't make sense. What is the expected behavior if the user checks two boxes, passing :course_id => ["2", "5"] in? You may have a belongs_to/has_many reversed here...

--Matt Jones

Help! Can anyone see why my code isn't inserting the course_id parameter into my table?

<p> <%= f.label :course_id %><br /> <t1> <% for course in current_user.courses.find(:all, :order => 'order_taught') %>

 &lt;%= check\_box\_tag &#39;assessment\[course\_id\]\[\]&#39;, course\.id %&gt;
 &lt;%=h course\.name %&gt;

<% end %> </p>

Below, you can see the Development Log. It shows that the parameter for "course_id"=>["2"]. But as you can see, the INSERT INTO is inserting a value of 1 for course_id:

I guess the problem is that course_id is being passed as an array due to the in the check_box_tag call. Would a radio set be more appropriate so only one can be selected?

Colin

Demetrius, could you show us the controller code which handles that form?