I am currently looking for a software/web development job preferably as a Rails-based developer.
Please email me at weston@westonganger.com. Thanks in advance for any leads!

Getting A Users Change History Using Audited Gem

Posted by Weston Ganger

Using the audited gem they didnt clearly define how to get a list of all of the changes / history the user has made. I wrote a method to do this

class User < ActiveRecord::Base
  #include Audited ###if your not using Rails or trying this on a different class that is not hooked up to audited yet

  def history
    Audited.audit_class.where(user_id: self.id).order(created_at: :desc)

Then it can be used like so:


Make that into an each and generate the history page for your user!

Article Topic:Software Development - Rails

Date:October 17, 2015

Recommended Posts