Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:15:14+00:00 2026-06-08T17:15:14+00:00

I am using paper trail to audit changes to data and would like to

  • 0

I am using paper trail to audit changes to data and would like to store the user_id of the current user in addition to the “whodunnit” column that paper_trail stores by default.

I had no trouble modifying the versions migration to add the user_id column. But I haven’t figured out an easy way to set that column from the various models in my app.

It seems like this should work:

has_paper_trail :meta => { :user_id  => current_user.id
                       }

And, I think it might work if I had access to the current_user in my models. But I don’t. After researching how to get access to the current_user in my model, I see there is a philosophical debate here. That’s not my question though.

So I’m thinking of using a gem like sentient_user or sentient_model to give me access to the current_user in my models so I can set it with something like the code above.

However, adding these gems seems complicated for the little thing I’m trying to do here. I’m wondering if there is an easier way.

What is the easiest way to add the user_id of the person who took the action to the versions table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:15:16+00:00Added an answer on June 8, 2026 at 5:15 pm

    The current_user don’t exists in models by itself, it appears from controller. So, standard approach is applicable:

    class ApplicationController < ActionController::Base
      def user_for_paper_trail
        current_user if user_signed_in?
      end
    
      def info_for_paper_trail
        { user_id: current_user.id } if user_signed_in?
      end
    end
    
    # config/initializers/paper_trail.rb
    class Version < ActiveRecord::Base
      attr_accessible :user_id
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using paper trail with Rails 3.1 and would like to get a
I am developing ' Paper Toss' for iphone using cocos2d & I would like
I would like to create an origami-like paper folding animation using WebGL or Canvas
I am using paper_trail for audit trail. Along with create, update and delete events
I'm trying to determine the current paper type selection on the default printer using
I can get the current Locale paper size using GetLocaleStr(LCID,LOCALE_IPAPERSIZE,IntToStr(DMPAPER_A4)) where LOCALE_IPAPERSIZE = $100A
I'm using visual studio and I'd like to have a paper copy of my
I am writing a paper using the ACM template which capitalizes every letter in
I'm using the LLNCS layout for a latex paper. The page numbers are suppressed
I wrote a research paper in latex and generated pdf using Kile. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.