Sunday, September 23, 2007

Updating checkboxes

Ran into the weirdest problem today. I have a couple check-boxes on a form. Using form_for to display the check-box fields for update. Even though the submit action on the form delivers the correct params for the check-box fields, the user.update_attributes(params[:user]) generates a SQL UPDATE statement with the wrong values - but only for the check-boxes. All other fields are fine. Here's two screen shots from the development.log that illustrate it.

To work around it, I just added user.update_attribute(:email_1, params[:user][:email_1]) and saved it.


No comments: