vendredi 11 septembre 2015

Private methods in Ruby

An example of Rails controller which defines a private method:

class ApplicationController < ActionController::Base
  private
  def authorization_method
    # do something
  end
end

Then, it's being used in subclass of "ApplicationController":

class CustomerController < ApplicatioController
  before_action :authorization_method

  # controller actions
end

My question is: how is it possible, that private method be called from subclass? What is meaning of private in Ruby?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire