method
toggle
toggle(attribute)
public
Assigns to attribute the boolean opposite of attribute?. So if the predicate returns true the attribute will become false. This method toggles directly the underlying value without calling any setter. Returns self.
Register or
log in
to add new notes.
insane-dreamer -
April 12, 2009
tobago -
March 11, 2010
0 thanks
Takes attribute as a symbol
Attribute must be passed as a symbol:
User.toggle(:funny)
not
User.toggle(funny)
0 thanks
Skips validations and callbacks
The method skips validations and callbacks. That is why it should be used with caution.
Code example
person.toggle :active


