collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.39k stars 671 forks source link

Audit Globalize translations #158

Open mtpersonalfile opened 11 years ago

mtpersonalfile commented 11 years ago

Trying to audit fields that are translated with globalize, with no success. I can audit all fields in table Persons, and all associated models, like contacts and notes, but don't know how to include translation tables (preson_translatios). Any suggestions or help please. Thanx

Example:

class Person < ActiveRecord::Base translates :first_name, :last_name accepts_nested_attributes_for :translations

has_many :contacts, as: :contactable, dependent: :destroy has_many :notes, as: :notable, dependent: :destroy

audited :allow_mass_assignment => true has_associated_audits

mastermike14 commented 10 years ago

+1

BrahimDahmani commented 8 years ago

+1

maxivak commented 6 years ago

I managed it with reopening translation class inside my model:

class Mymodel < ApplicationRecord

  # translation
  translates :first_name, :last_name

  # audit - audit base table
  audited

  # ADD THIS to audit translation
  Translation.class_eval do
    audited
  end

see full example here: https://gist.github.com/maxivak/e1c6b39b9ec5a16d2d3daacbdd2a64d4