if my database is set to as false, whats the best practice in updating boolean value in database?
I can do it on console:
>> u = User.find_by_id(1)
What do I do next?
Thanks
If you want to toggle the boolean:
u.toggle!(:<attribute>) # Toggles the boolean and saves without validations
u.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 callbacks
u.update_attribute(:<attribute>, [true|false]) # Updates timestamps and triggers any callbacks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With