aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_callbacks.md
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2016-12-23 20:17:32 +0900
committerAkira Matsuda <ronnie@dio.jp>2016-12-25 02:15:32 +0900
commit0e109c871033ccff396709a76ec3af05257f4560 (patch)
treeb00c1e40d8f8ea563165c5ed7bd02fda12502360 /guides/source/active_record_callbacks.md
parentd1daf4c31301f5f5917b877fd63a817f5f4608ed (diff)
downloadrails-0e109c871033ccff396709a76ec3af05257f4560.tar.gz
rails-0e109c871033ccff396709a76ec3af05257f4560.tar.bz2
rails-0e109c871033ccff396709a76ec3af05257f4560.zip
Abuse of protected in guides
Diffstat (limited to 'guides/source/active_record_callbacks.md')
-rw-r--r--guides/source/active_record_callbacks.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md
index 2a1c960887..868daf2435 100644
--- a/guides/source/active_record_callbacks.md
+++ b/guides/source/active_record_callbacks.md
@@ -36,7 +36,7 @@ class User < ApplicationRecord
before_validation :ensure_login_has_a_value
- protected
+ private
def ensure_login_has_a_value
if login.nil?
self.login = email unless email.blank?
@@ -66,7 +66,7 @@ class User < ApplicationRecord
# :on takes an array as well
after_validation :set_location, on: [ :create, :update ]
- protected
+ private
def normalize_name
self.name = name.downcase.titleize
end
@@ -77,7 +77,7 @@ class User < ApplicationRecord
end
```
-It is considered good practice to declare callback methods as protected or private. If left public, they can be called from outside of the model and violate the principle of object encapsulation.
+It is considered good practice to declare callback methods as private. If left public, they can be called from outside of the model and violate the principle of object encapsulation.
Available Callbacks
-------------------