Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when is after_touch callback in rails called

How does after_touch callback work in Rails? Is it called whenever an object is updated or only when a new object is created?

like image 478
Hellboy Avatar asked Jul 21 '15 11:07

Hellboy


People also ask

Are rails callbacks Asynchronous?

Guideline #2: Asynchronous by defaultWhenever we add a callback, that is code that will execute before we can respond to a request. If a class defines 20 callbacks, that's 20 blocks of code that must execute before we can respond to the user.

What is controller callback in rails?

Abstract Controller Callbacks Abstract Controller provides hooks during the life cycle of a controller action. Callbacks allow you to trigger logic during this cycle. Available callbacks are: after_action. append_after_action.

What is Active Record in Ruby on Rails?

What is ActiveRecord? ActiveRecord is an ORM. It's a layer of Ruby code that runs between your database and your logic code. When you need to make changes to the database, you'll write Ruby code, and then run "migrations" which makes the actual changes to the database.

What is After_commit?

after_commit is a type of active record callback.


1 Answers

It'll be called only if the object is touched:

object.touch # after_touch will be called

Here you could find more info.

like image 108
Mario Pérez Avatar answered Sep 20 '22 06:09

Mario Pérez