在下面的代码中,为什么foo_enabled?
要求EmployeeController.bar
?何时在Rails应用程序中执行条件before_action方法?
class ApplicationController < ActionControlelr::Base
before_action :foo, if: :foo_enabled?
def foo
puts 'foo called'
end
def foo_enabled?
puts 'sleep for 100s !'
true
end
end
class EmployeeController < ApplicationController
skip_before_action :foo, only: [:bar]
def bar
puts 'inside bar'
end
end