Method: ActiveRecord::Base#toggle
- Defined in:
- lib/active_record/base.rb
#toggle(attribute) ⇒ Object
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.
2723 2724 2725 2726 |
# File 'lib/active_record/base.rb', line 2723 def toggle(attribute) self[attribute] = !send("#{attribute}?") self end |