Skip to content

Instantly share code, notes, and snippets.

@jackdempsey
Created September 5, 2012 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackdempsey/3629016 to your computer and use it in GitHub Desktop.
Save jackdempsey/3629016 to your computer and use it in GitHub Desktop.
How to define controller methods in one place for ActiveAdmin
109 class ActiveAdmin::BaseController
110 def current_ability
111 @current_admin_ability ||= AdminAbility.new(current_admin_user)
112 end
113
114 def user_for_paper_trail
115 current_admin_user
116 end
117
118 def info_for_paper_trail
119 {whodunnit_type: 'AdminUser'}
120 end
121 end
In normal ApplicationController I define a info_for_paper_trail with User being the resulting value. Then later on I can see if a User or AdminUser caused the change.
HTH
jack
109 class ActiveAdmin::BaseController
110 def current_ability
111 @current_admin_ability ||= AdminAbility.new(current_admin_user)
112 end
113
114 def user_for_paper_trail
115 current_admin_user
116 end
117
118 def info_for_paper_trail
119 {whodunnit_type: 'AdminUser'}
120 end
121 end
In normal ApplicationController I define a info_for_paper_trail with User being the resulting value. Then later on I can see if a User or AdminUser caused the change.
HTH
jack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment