Reputation: 3341
First off, I am totally new with gems
and engines
(eh. ruby
);
I am writing a handy engine
which is going to filter requests based on the rules
the user(developer) defines, currently my approach is the following:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action { Acu::Monitor.new request }
end
And it works like a charm, but I want the engine to be plug-n-play with minimum configuration by the user, is there anyway I can achive this?
Can I get anywhere between dispatch and controller, where I can validate the request? Is there something like pre-dispatch-event
in rails?
I would really appreciate if anyone help me on this, I got tired of google this, kind of ran out of query to write! :D
requests has to be processed, i.e the target controller/action need to be determined by rails then I am processing the request.
Upvotes: 0
Views: 656
Reputation: 3341
I found the answer, it is the instrumentation that I was looking for
ActiveSupport::Notifications.subscribe "start_processing.action_controller" do |**args|
# your own custom stuff
end
This way # your own custom stuff
will start to fire before the before_action
!
Upvotes: 1