Skip to content

Commit 0e109c8

Browse files
committed
Abuse of protected in guides
1 parent d1daf4c commit 0e109c8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

guides/source/action_cable_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module ApplicationCable
6262
self.current_user = find_verified_user
6363
end
6464

65-
protected
65+
private
6666
def find_verified_user
6767
if current_user = User.find_by(id: cookies.signed[:user_id])
6868
current_user

guides/source/active_record_callbacks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class User < ApplicationRecord
3636

3737
before_validation :ensure_login_has_a_value
3838

39-
protected
39+
private
4040
def ensure_login_has_a_value
4141
if login.nil?
4242
self.login = email unless email.blank?
@@ -66,7 +66,7 @@ class User < ApplicationRecord
6666
# :on takes an array as well
6767
after_validation :set_location, on: [ :create, :update ]
6868

69-
protected
69+
private
7070
def normalize_name
7171
self.name = name.downcase.titleize
7272
end
@@ -77,7 +77,7 @@ class User < ApplicationRecord
7777
end
7878
```
7979

80-
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.
80+
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.
8181

8282
Available Callbacks
8383
-------------------

guides/source/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ NOTE: A frequent practice is to place the standard CRUD actions in each
827827
controller in the following order: `index`, `show`, `new`, `edit`, `create`, `update`
828828
and `destroy`. You may use any order you choose, but keep in mind that these
829829
are public methods; as mentioned earlier in this guide, they must be placed
830-
before any private or protected method in the controller in order to work.
830+
before any private method in the controller in order to work.
831831

832832
Given that, let's add the `show` action, as follows:
833833

0 commit comments

Comments
 (0)