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:
http://en.wikipedia.org/wiki/Object-oriented_programming.

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:
http://en.wikipedia.org/wiki/Object-oriented_programming.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs