Method: ActiveRecord::Base#toggle
- Defined in:
- lib/active_record/base.rb
#toggle(attribute) ⇒ Object
Turns an attribute that’s currently true into false and vice versa. Returns self.
856 857 858 859 |
# File 'lib/active_record/base.rb', line 856 def toggle(attribute) self[attribute] = quote(!send("#{attribute}?", column_for_attribute(attribute))) self end |