Questions tagged [paper-trail-gem]

a Ruby gem for tracking changes in your model data

PaperTrail is a Ruby gem for tracking changes in your model data. It does this by recording all create, update, and destroy actions in instances of your models that call has_paper_trail. Versions of tracked models can be retrieved via their versions method.

PaperTrail was originally developed by Andy Stewart at AirBlade Software.

Usage Example

class Example < ActiveRecord::Base
  has_paper_trail
end

example = Example.new(name: "Ruby")
example.name                                 # "Ruby"

example.update_attribute(:name, "Rails")
example.name                                 # "Rails"

example.versions.last.reify.name             # "Ruby"
example.versions.last.event                  # "update"

Resources

297 questions
22
votes
2 answers

How to rectify versions on has_many/belongs_to association with paper_trail

I use paper_trail in rails to track my models versions. But the documentation on the github repo indicates that the gem doesn't support has_many, belongs_to associations. Let's say I've an app that records the ceos names of some comapnies: class…
blawzoo
  • 2,465
  • 4
  • 19
  • 24
13
votes
5 answers

Find version where specific attribute has changed in papertrail

I'm using the Papertrail gem in my project and have searched extensively to try and find how to do the following. What I'd like to do is find the version of my object where a specific attribute came to be a specific value…
Betjamin Richards
  • 1,071
  • 2
  • 12
  • 34
13
votes
2 answers

After installing paper_trail, get "irb: warn: can't alias context from irb_context." from rails console

I've tested this by running rails c both before and after git stash. On Rails 4.1 in Mavericks, after following the instructions to add the versions table and adding has_paper_trail to three models, whenever I run rails c I get irb: warn: can't…
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
12
votes
5 answers

Logstash log tail in browser

So I setup Logstash 1.4.2 with ElasticSearch and Kibana using logstash-forwarder(lumberjack) and thats working pretty well but I also wanted to show just a raw log output(maybe searchable) via a browser similar to something like papertrail? Is this…
arduima
  • 413
  • 6
  • 13
11
votes
1 answer

Is there an equivalent of the PaperTrail gem in Rails for NodeJS?

I'm looking for something for NodeJS that is similar to the PaperTrail gem for rails. Something that will automatically help keep track of changes to different fields.
JoshEmory
  • 644
  • 6
  • 20
10
votes
2 answers

(Rails) PaperTrail and RSpec

I'm having trouble with PaperTrail (auto-versioning of objects for Rails) being used with RSpec tests. Normally I want my tests to run without PaperTrail versioning, but there are a handful of tests for which I want PaperTrail turned on. I typically…
JacobEvelyn
  • 3,901
  • 1
  • 40
  • 51
9
votes
6 answers

Papertrail and Carrierwave

I have a model that use both: Carrierwave for store photos, and PaperTrail for versioning. I also configured Carrierwave for store diferent files when updates (That's because I want to version the photos) with…
eveevans
  • 4,392
  • 2
  • 31
  • 38
9
votes
2 answers

How to set whodunnit for paper_trail when creating a new user?

The paper_trail gem tracks versions, and does a good job. However, there is one edge case I've been noticing. For most objects, the application controller sets whodunnit if you are logged in, and then all objects that are created during that session…
Rob
  • 4,404
  • 2
  • 32
  • 33
9
votes
3 answers

Friendly ID - undefined method `slug=' for

I am using the gems Workflow, Paper Trail and Friend ID. To track the state changes using Paper Trail, I have overridden the persist_workflow_state to explicitly update the workflow column, so that Paper Trail can capture the…
Geordee Naliyath
  • 1,799
  • 17
  • 28
8
votes
3 answers

How to track custom events in paper_trail?

I am using paper_trail for audit trail. Along with create, update and delete events I want to track few custom events like view(record), sent(email) etc. How can we introduce such custom events while auditing a model?
Amit Patel
  • 15,609
  • 18
  • 68
  • 106
8
votes
2 answers

Rails / Papertrail: Changeset with association changes

I am stuck. I've been trying to figure out how to include the association changes (has_many, has_many through) on a model that has papertrail. I would like to call MyModel.versions.first.changeset and have any changes that took place on associated…
8
votes
3 answers

PaperTrail Manually create version

I have a spreadsheet of items which I convert to CSV and import using a custom import script into my Rails based application. The spreadsheet contains a row for each record but some rows hold different versions of previous rows. When importing the…
rctneil
  • 7,016
  • 10
  • 40
  • 83
7
votes
2 answers

Query jsonb array for integer member

Background: We use PaperTrail to keep the history of our changing models. Now I want to query for a Item, which belonged to a certain customer. PaperTrail optionally stores the object_changes and I need to query this field to understand, when…
iGEL
  • 16,540
  • 11
  • 60
  • 74
7
votes
1 answer

Using PaperTrail, can I opt out of `object_changes` for a particular model or attribute?

This is somewhat related to #837 in that I have a large data column on my models, however I think I may be better served by the opposite of what's proposed in that issue - that is, to maintain the object column but not the object_changes column. We…
Gabe Kopley
  • 16,281
  • 5
  • 47
  • 60
7
votes
1 answer

Paper_trail gem: uninitialized constant VersionsController::Version

I had this working fine following the Railscast episode by Ryan Bates and then some weeks later I went back to check on it and it was borked. Now I'm getting this error whenever I hit the undo button: uninitialized constant…
John Trichereau
  • 626
  • 9
  • 22
1
2 3
19 20