module

Granite::Transactions

Instance methods

destroy

Removes the record from the database. Returns true if successful, false otherwise.

Source
destroy!

Same as #destroy, but raises Granite::RecordNotDestroyed if unsuccessful.

Source
save(*, validate : Bool = true, skip_timestamps : Bool = false)

Attempts to save the record to the database, returning true if successful, and false if not. If the save is unsuccessful, #errors will be populated with the errors which caused the save to fail.

NOTE: This method can be used both on new records, and existing records. In the case of new records, it creates the record in the database, otherwise, it updates the record in the database.

Source
save!(*, validate : Bool = true, skip_timestamps : Bool = false)

Same as #save, but raises Granite::RecordNotSaved if the save is unsuccessful.

Source
set_timestamps(*, to time = Time.local(Granite.settings.default_timezone), mode = :create)

Sets the record's timestamps(created_at & updated_at) to the current time.

Source
touch(*fields) : Bool

Updates the updated_at field to the current time, without saving other fields.

Raises error if record hasn't been saved to the database yet.

Source
update(args, skip_timestamps : Bool = false)

Updates the record with the new data specified by args, with the option to not update timestamps. Returns true if the update is successful, false if it isn't.

Source
update

Updates the record with the new data specified by args. Returns true if the update is successful, false if it isn't.

Source
update!(args, skip_timestamps : Bool = false)

Updates the record with the new data specified by args, with the option to not update timestamps. Raises Granite::RecordNotSaved if the save is unsuccessful.

Source
update!

Updates the record with the new data specified by args. Raises Granite::RecordNotSaved if the save is unsuccessful.

Source

Nested types