instance method toggle

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

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

attribute req
Source
# File activerecord/lib/active_record/base.rb, line 2519
      def toggle(attribute)
        self[attribute] = !send("#{attribute}?")
        self
      end

Defined in activerecord/lib/active_record/base.rb line 2519 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close