class ApplicationController < ActionController::Base private def authorization_method # do something end end
然后,它被用在ApplicationController的子类中:
class CustomerController < ApplicatioController before_action :authorization_method # controller actions end
如何从其子类调用私有方法? private in Ruby是什么意思?
Here是Ruby中公共,受保护和私有方法的一个很好的解释.