aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_record_callbacks.md27
-rw-r--r--guides/source/layouts_and_rendering.md2
2 files changed, 26 insertions, 3 deletions
diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md
index 614737c342..8f54e78224 100644
--- a/guides/source/active_record_callbacks.md
+++ b/guides/source/active_record_callbacks.md
@@ -473,10 +473,33 @@ end
=> User was saved to database
```
-To register callbacks for both create and update actions, use `after_commit` instead.
+There is also an alias for using the `after_commit` callback for both create and update together:
+
+* `after_save_commit`
+
+```ruby
+class User < ApplicationRecord
+ after_save_commit :log_user_saved_to_db
+
+ private
+ def log_user_saved_to_db
+ puts 'User was saved to database'
+ end
+end
+
+# creating a User
+>> @user = User.create
+=> User was saved to database
+
+# updating @user
+>> @user.save
+=> User was saved to database
+```
+
+To register callbacks for both create and destroy actions, use `after_commit` instead.
```ruby
class User < ApplicationRecord
- after_commit :log_user_saved_to_db, on: [:create, :update]
+ after_commit :log_user_saved_to_db, on: [:create, :destroy]
end
```
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index 43cc958cb1..2808527141 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -420,7 +420,7 @@ If a template with the specified format does not exist an `ActionView::MissingTe
##### The `:variants` Option
-This tells rails to look for template variations of the same format.
+This tells Rails to look for template variations of the same format.
You can specify a list of variants by passing the `:variants` option with a symbol or an array.
An example of use would be this.