I see two difference experience in rails. In multiple projects permit_params
are defined in protected
and in multiple projects they are defined in private
What is the difference between these two strategies?
Please explain briefly
I see two difference experience in rails. In multiple projects permit_params
are defined in protected
and in multiple projects they are defined in private
What is the difference between these two strategies?
Please explain briefly
private
The type or member can only be accessed by code in the same class.
protected
The type or member can only be accessed by code in the same class or struct, or in a derived class.
An example of a private method: http://matthodan.com/2010/08/08/ruby-private-methods-vs-protected-methods.html