解决方法
如果要切换布尔值:
u.<attribute>.toggle! # Toggles the boolean and saves without validations u.<attribute>.toggle # Toggles the boolean and does not save
如果要设置布尔值:
u.<attribute> = [true|false]
如果要立即更新布尔值:
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