Created
September 5, 2012 01:48
-
-
Save jackdempsey/3629016 to your computer and use it in GitHub Desktop.
How to define controller methods in one place for ActiveAdmin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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