0
def user_for_paper_trail
admin_user_signed_in? ? current_admin_user : current_user
end
這是我paper_trail是如何記錄用戶ID,但我怎麼它能區分whodunnit
記錄了AdminUser
或User
?分化whodunnit記錄ADMINUSER或用戶 - paper_trail
def user_for_paper_trail
admin_user_signed_in? ? current_admin_user : current_user
end
這是我paper_trail是如何記錄用戶ID,但我怎麼它能區分whodunnit
記錄了AdminUser
或User
?分化whodunnit記錄ADMINUSER或用戶 - paper_trail
您可能需要在versions
表中添加一個名爲whodunnit_type
的列。
然後你就可以添加一個名爲info_for_paper_trail
到控制器方法存儲模型的類名:
def info_for_paper_trail
{ whodunnit_type: (admin_user_signed_in? ? current_admin_user.class.name : current_user.class.name) }
end