I had Paper Trail Gem nicely set up with my basic model Article which had a text
column called body
. However, after I have implemented Action Text to my application and removed the column body
from the Article model, I can't get Paper Trail to track changes in associated body
column. How can I get this to work?
Disclaimer: I am a newbie to Rails.
Article.rb
...
has_rich_text :body
has_paper_trail
...
Articles Schema (after deleting :body column)
create_table "articles", force: :cascade do |t|
t.string "title"
t.string "slug"
t.datetime "archived_at"
t.datetime "published_at"
...
end
Action Text Schema
create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
t.text "body"
t.string "record_type", null: false
t.bigint "record_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end
I'd love to return the same functionality to the app as before where I was able to see the changes made in the body of the Article. E.g. someone added a sentence, deleted a word, etc..
After trying all the options provided here, I got an idea for this workaround that at the end worked really well.
What I did is that I simply replaced Action Text with pure Trix Editor version and therefore I was able to keep :body
within my article.rb model, save the versions of the whole object and show diffs. Yay! 🎉