method

toggle

toggle(attribute)
public

Turns an attribute that’s currently true into false and vice versa. Returns self.

2Notes

Skips validations and callbacks

tobago · Mar 11, 20101 thank

The method skips validations and callbacks. That is why it should be used with caution.

==== Code example

person.toggle :active

Takes attribute as a symbol

insane-dreamer · Apr 11, 2009

Attribute must be passed as a symbol:

User.toggle(:funny)

not

User.toggle(funny)