What is protected?

In http://www.aidanf.net/rails_user_authentication_tutorial there is the
string/method

protected

in the model. What does it do? Can’t find that in
http://api.rubyonrails.org/.

This is OOP visibility encapsulate mechanism.
Learn more at:
Object-oriented programming - Wikipedia.

On 7/6/06, PÃ¥l Bergström [email protected] wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Everton J. Carpes
Mobile: +55 53 9129.4593
MSN: [email protected]
UIN: 343716195
Jabber: [email protected]
Gestum
http://www.gestum.com.br/
O.S. Systems
http://www.ossystems.com.br
http://projects.ossystems.com.br

Everton J. Carpes wrote:

This is OOP visibility encapsulate mechanism.
Learn more at:
Object-oriented programming - Wikipedia.

thanks :slight_smile:

Protected methods can only be invoked via the class itself (and
friends).

Practically, in rails controllers, this means the method can’t be
accessed via the web.

Pål Bergström wrote:

In http://www.aidanf.net/rails_user_authentication_tutorial there is the
string/method

protected

in the model. What does it do? Can’t find that in
http://api.rubyonrails.org/.

It’s a feature of Ruby, not of Rails.

Within a class definition, it marks the following methods as protected
(i.e. accessible to that class and its subclasses, not accessible to
other classes).

‘public’ (accessible to any class) and ‘private’ (accessible only to
this class) work similarly.

In Rails controllers you should take care to make methods that are not
to be used as actions via HTTP either private or protected.

regards

Justin

Inge Jørgensen wrote:

Protected methods can only be invoked via the class itself (and
friends).

Practically, in rails controllers, this means the method can’t be
accessed via the web.

Not sure I follow.