save!

save!(*) Instance Public methods Saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated. With save! validations always run. If any of them fail ActiveRecord::RecordInvalid gets raised. See ActiveRecord::Validations for more information. There's a series of callbacks associated with save!. If any of the before_* callbacks return false the action is cancelled and save! raises ActiveRecord::RecordNotSaved. See ActiveRecor

save

save(*) Instance Public methods Saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated. By default, save always run validations. If any of them fail the action is cancelled and save returns false. However, if you supply validate: false, validations are bypassed altogether. See ActiveRecord::Validations for more information. There's a series of callbacks associated with save. If any of the before_* callbacks return fals

reload

reload(options = nil) Instance Public methods Reloads the record from the database. This method finds record by its primary key (which could be assigned manually) and modifies the receiver in-place: account = Account.new # => #<Account id: nil, email: nil> account.id = 1 account.reload # Account Load (1.2ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT 1 [["id", 1]] # => #<Account id: 1, email: 'account@example.com'> Attributes are reloa

persisted?

persisted?() Instance Public methods Returns true if the record is persisted, i.e. it's not a new record and it was not destroyed, otherwise returns false.

new_record?

new_record?() Instance Public methods Returns true if this object hasn't been saved yet รข that is, a record for the object doesn't exist in the database yet; otherwise, returns false.

increment!

increment!(attribute, by = 1) Instance Public methods Wrapper around increment that saves the record. This method differs from its non-bang version in that it passes through the attribute setter. Saving is not subjected to validation checks. Returns true if the record could be saved.

increment

increment(attribute, by = 1) Instance Public methods Initializes attribute to zero if nil and adds the value passed as by (default is 1). The increment is performed directly on the underlying attribute, no setter is invoked. Only makes sense for number-based attributes. Returns self.

destroyed?

destroyed?() Instance Public methods Returns true if this object has been destroyed, otherwise returns false.

destroy!

destroy!() Instance Public methods Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). There's a series of callbacks associated with destroy!. If the before_destroy callback return false the action is cancelled and destroy! raises ActiveRecord::RecordNotDestroyed. See ActiveRecord::Callbacks for further details.

destroy

destroy() Instance Public methods Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). There's a series of callbacks associated with destroy. If the before_destroy callback return false the action is cancelled and destroy returns false. See ActiveRecord::Callbacks for further details.