ruby-on-railsrubyactiverecordpaper-trail-gemglobalize3

ActiveRecord object does not save translated values with paper trail gem


We are using Rails 3.2.15 and Globalize gem for I18N. We recently integrated Paper Trail Gem for auditing Model changes.

We observed that whichever model fields are marked as translated are not updated in DB.

e.g.

class MyModel < ActiveRecord::Base
  translates :name
  has_paper_trail
end

When I update the name attribute of MyModel object, it is not saved.

Versions:

Ruby 1.9.3

Rails 3.2.15

Globalize3

paper_trail 2.7.2


Solution

  • I got it to work by upgrading my Globalize gem and installing the globalize-versioning gem. It works quite well together.

    class MyModel < ActiveRecord::Base
      translates :name, versioning: :paper_trail
      has_paper_trail
    end
    

    This does require you to get versions for translated items with my_model.translations.versions instead of the usual my_model.versions.