Question

  def user_for_paper_trail
    admin_user_signed_in? ? current_admin_user : current_user
  end

This is how my paper_trail is recording the user ID, but how can I differentiate that whodunnit recorded an AdminUser or User?

Was it helpful?

Solution

You'll probably want to add a column called whodunnit_type to your versions table.

Then you can add a method called info_for_paper_trail to your controller that stores the model's class name:

def info_for_paper_trail
  { whodunnit_type: (admin_user_signed_in? ? current_admin_user.class.name : current_user.class.name) }
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top