Alexander Gorg
Alexander Gorg

Reputation: 1078

Using private and protected methods in one controller in Rails

All the articles say about the difference between private and protected methods, however there's no clearance about using it.

So if code something like:

private
  def my_method
    #some code
  end

Does private affect only the my_method or everything below?

UPDATE: And if affects everything what if I want to use protected methods as well? If I code below my_method:

protected
  def another_method
    #some code
  end

Does it mean that private method has ended and protected methods section has started?

Upvotes: 0

Views: 151

Answers (1)

jbehrens94
jbehrens94

Reputation: 2406

To simply answer your question: yes, when you have the following code:

private
  ....

protected
  ....

Then private stops where protected begins.

Upvotes: 3

Related Questions