instance method
toggle
Ruby on Rails 4.2.9
Since v3.0.20Signature
toggle(attribute)
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.
Parameters
-
attributereq
Source
# File activerecord/lib/active_record/persistence.rb, line 346
def toggle(attribute)
self[attribute] = !send("#{attribute}?")
self
end
Defined in activerecord/lib/active_record/persistence.rb line 346
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Persistence