Flowdock
method

toggle

Importance_2
v1.2.6 - Show latest stable - 2 notes - Class: ActiveRecord::Base
toggle(attribute) public

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

Show source
Register or log in to add new notes.
March 11, 2010
1 thank

Skips validations and callbacks

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

Code example

person.toggle :active
April 12, 2009
0 thanks

Takes attribute as a symbol

Attribute must be passed as a symbol:

User.toggle(:funny)

not

User.toggle(funny)