I have api controller which is inherited from ActionController::API
API authentication is performed with some organization key like
api_key = request.headers["HTTP_AUTHORIZATION_TOKEN"]
@organization = Organization.find_by(api_key: api_key)
later I need to set whodunnit & whodunnit_type with @organization
there are multiple type of organizations
Question:
How can I make call to paper_trail method info_for_paper_trail after authentication
Currently what's happening
info_for_paper_trail method is being called before authentication and at that time there is no @organization
What I tried:
1- I tried before_action filter in controller after authentication BUT what happens
info_for_paper_trailmethod is called 2 times one by default (by PaperTrail) other one which I set bybefore_action. In first attempt there is no@organizationbut in second attempt viabefore_actionit setwhodunnit & whodunnit_typebut not saved in db entry of version table.- Secondly called
info_for_paper_trailmethod inside authentication method which also setwhodunnit & whodunnit_typebut it's not being saved in version table entry.