paper-trail-gem

PaperTrail: info_for_paper_trail outside the context of a controller

佐手、 提交于 2019-12-04 10:53:42
I am using the paper_trail gem for versioning my models. So far, my model depends on the info_for_paper_trail method in ApplicationController : class ApplicationController < ActionController::Base # Extra columns to store along with PaperTrail `versions` def info_for_paper_trail { revision_id: @revision.id, revision_source_id: @revision_source.id } end end This works great in context of the controller, but is there a way that I can replicate this sort of thing outside the context of the controller (e.g., a delayed job)? I tried creating a virtual attribute called revision and passing a proc

Papertrail and Carrierwave

我们两清 提交于 2019-12-03 12:23:38
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 config.remove_previously_stored_files_after_update = false The problem is that PaperTrail try to store the whole Ruby Object from the photo (CarrierWave Uploader) instead of simply a string (that would be its url) (version table, column object) --- first_name: Foo last_name: Bar photo: !ruby/object:PhotoUploader model: !ruby/object:Bla attributes: id: 2 first_name: Foo1 segundo_nombre:

NoMethodError - undefined method `timestamp_sort_order' for Paper trail issue after upgrading Rails 4.2

南楼画角 提交于 2019-12-01 21:26:18
问题 I used paper_trail to tracking transnational changes when I migrated rails 3.2 to rails 4.2, have got below issue: NoMethodError - undefined method `timestamp_sort_order' for 回答1: I fixed this by adding below line in intializer paper_trail.rb file PaperTrail::Rails::Engine.eager_load! See my final intializers/paper_trail.rb file PaperTrail::Rails::Engine.eager_load! module PaperTrail class Version < ActiveRecord::Base ..... end end Problem resolved.... 回答2: got this on rails 6.0.0beta3

Display all versions of individual records in Papertrail

和自甴很熟 提交于 2019-12-01 12:42:47
I'm building a league system and currently it stores and updates the players 'elo score' depending on the result. Now, I'm trying to add in 'HighCharts' to display the players elo score over the season in a sweet looking line chart. Someone suggested I use Papertrail to store the updates and I have got that all installed. Now here comes my problem, I can't seem to figure out how to spit out the users elo_score versions in an array easy for 'HighCharts' to use. I can get the last updates to elo_score: Last updated score = <%= @player.versions.last.reify.elo_score %> But I can't seem to find the

Paper Trail: create a version on parent whenever associated model changes?

孤街醉人 提交于 2019-11-30 22:31:40
I'm working on a Rails app where I need to show the audit trail on a Record , which has_many Data . I have paper_trail on my Record, and associated Datum models, and it is saving versions of them just fine. However, what I need is for one version for Record to be created whenever one or more associated Data are changed. Currently, it creates versions on each Datum that changes, but it only creates a version of the Record if the Record's attributes change; it's not doing it when the associated Data change. I tried putting touch_with_version in Record's after_touch callback, like so: class