diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-12-29 02:18:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-29 02:18:38 -0500 |
commit | eb6a6141a66e052deb58580448d7c0fa6aa675ba (patch) | |
tree | 0017a57044ec8e466c97cc6b7879d39caa6c1ffa /guides/source/active_record_callbacks.md | |
parent | 447e1a48811fa053e8bef954376d1ad47bdb5cef (diff) | |
parent | fcec126eaa4f835c837bc75efa78008667b2ec5b (diff) | |
download | rails-eb6a6141a66e052deb58580448d7c0fa6aa675ba.tar.gz rails-eb6a6141a66e052deb58580448d7c0fa6aa675ba.tar.bz2 rails-eb6a6141a66e052deb58580448d7c0fa6aa675ba.zip |
Merge branch 'master' into clear_all_environments_log_by_default
Diffstat (limited to 'guides/source/active_record_callbacks.md')
-rw-r--r-- | guides/source/active_record_callbacks.md | 6 |
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 ------------------- |