Это был простой взлом, но единственный способ, которым я мог бы подумать, что проверка перед фильтром будет инициализирована. Следующие проверки, если у контроллера есть фильтр до/после, который использует несуществующее действие, и вызывает сообщение об исключении, если оно
# config/initializers/before_filters.rb
# require all controllers
Dir['app/controllers/*'].each do |path|
require path.split('/').last if path.include? '.rb'
end
# get array of all controllers
controllers = ApplicationController.descendants
controllers.each do |controller|
# get all filters for this controller
filters = controller._process_action_callbacks
# get all actions under this controller
actions = controller.action_methods.to_a
filters.each do |filter|
# get all action_conditions for this filter
action_conditions = filter.instance_variable_get(:@if)
# raise error message if action used in filter not in available controller actions
action_conditions.each do |action_condition|
if actions.none? {|action| action_condition.include? action }
message = "#{controller.name} has a #{filter.kind.to_s} filter with a non-existant action (#{action_condition.scan(/'([^']*)'/)[0][0]})"
raise message
end
end
end
end