Last active
January 26, 2025 08:27
-
-
Save maxivak/e1c6b39b9ec5a16d2d3daacbdd2a64d4 to your computer and use it in GitHub Desktop.
Revisions
-
maxivak revised this gist
Dec 19, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,9 @@ Below is how to add audited to the translation model. # Audited and Globalize Globalize adds nested class Translation inside your model class. We will reopen Translation class inside my model to add 'audited': ``` class Mymodel < ApplicationRecord -
maxivak created this gist
Dec 19, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ * [Globalize](https://github.com/globalize/globalize) adds model translations to ActiveRecord models. * [Audited](https://github.com/collectiveidea/audited) is an ORM extension that logs all changes to your models. Using Audited gem it will only logs changes to the base model and ignore changes to the translation table. Below is how to add audited to the translation model. # Audited and Globalize Reope translation class inside my model: ``` class Mymodel < ApplicationRecord # translation translates :title, :description # audit audited # ADD THIS Translation.class_eval do audited end ``` # Install audited Gemfile ``` gem "audited" ``` * install db tables ``` rails generate audited:install rake db:migrate ``` # Globalize Gemfile ``` gem 'globalize', '~> 5.0.0' ``` * See https://github.com/globalize/globalize to install globalize.