Sunday, January 17, 2010

Re: [Rails] check_box_tag doesn't insert parameter into table

2010/1/17 Demetrius <demetriuso@hotmail.com>:
> 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:

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

>
> 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"}}
>   [4;36;1mUser Load (0.0ms) [0m    [0;1mSELECT * FROM "users" WHERE
> ("users"."id" = 12) LIMIT 1 [0m
>   [4;35;1mAssessment Create (0.0ms) [0m    [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!
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>
>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate