rai*_*ls8 8 ruby oop ruby-on-rails
Rails控制器的一个例子,它定义了一个私有方法:
class ApplicationController < ActionController::Base
private
def authorization_method
# do something
end
end
Run Code Online (Sandbox Code Playgroud)
然后,它被用在以下的子类中ApplicationController:
class CustomerController < ApplicatioController
before_action :authorization_method
# controller actions
end
Run Code Online (Sandbox Code Playgroud)
如何从其子类调用私有方法?privateRuby中的含义是什么?