Hi, This was probably because you used the check_box helper, which makes sure the browser always sends a value. See the documentation for the check_box helper:
=== Gotcha The HTML specification says unchecked check boxes are not successful, and thus web browsers do not send them. Unfortunately this introduces a gotcha: if an Invoice model has a paid flag, and in the form that edits a paid invoice the user unchecks its check box, no paid parameter is sent. So, any mass-assignment idiom like @invoice.update_attributes(params[:invoice]) wouldn’t update the flag. To prevent this the helper generates a hidden field with the same name as the checkbox after the very check box. So, the client either sends only the hidden field (representing the check box is unchecked), or both fields. Since the HTML specification says key/value pairs have to be sent in the same order they appear in the form and Rails parameters extraction always gets the first occurrence of any given key, that works in ordinary forms. - Eloy On Jan 12, 2009, at 5:05 PM, Antoine wrote: > > Dear all, > > Maybe i wasn't so clear, excuse me for my english ;-) > > My problem is simple .. > I didn't change the value of my checkboxes in my form but the core > function of rails was saying that the values currently change ! and > that's why rails update the values in mysql... and also return a wrong > information if i use the new fontions like : attributes_change, > attribute_changed?... > > I don't understand why ? > > thank you for your help ! > Antoine > > On Jan 8, 3:39 pm, Antoine <[email protected]> wrote: >> Dear all, >> >> I get a stupid bug and i don't know if there is something wrong in >> rails or if it is me doing a stupid thing. >> >> I have a checkbox called (ass_tg) in my form and when i saved my >> form , i write in my model: >> >> before_save :test >> >> def test >> puts "-----------------------" >> puts ass_tg_change >> puts "-------------------------" >> end >> >> I should have a nil answer but I get in my console : >> >> ----------------------- >> 0 >> 0 >> ------------------------- >> >> And I have this attributes save in the SQL log ..(I didn't change the >> status of the checkbox ...) >> >> UPDATE `companies` SET .... `ass_tg` = 0,...... WHERE `.... >> >> It seems like rails don't like integer attributes equal to 0 when it >> execute all the change functions (change, changed?, was ...) ?? >> >> Best regards, >> >> Thank you for your help, >> Antoine > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
