Ruby on Rails: Update boolean record in database
If you want to toggle the boolean:
u.toggle!(:<attribute>) # Toggles the boolean and saves without validationsu.toggle(:<attribute>) # Toggles the boolean and does not save
If you want to set the boolean:
u.<attribute> = [true|false]
If you want to update the boolean immediately:
u.update_column(:<attribute>, [true|false]) # Doesn't update timestamps or call callbacksu.update_attribute(:<attribute>, [true|false]) # Updates timestamps and triggers any callbacks
>> u.boolean_property = false>> u.save
where boolean_property
is the name of the property that you want to set to false.
That is the simplest way (just setting it directly), and there are other ways, depending on your needs:http://www.davidverhasselt.com/2011/06/28/5-ways-to-set-attributes-in-activerecord/