我有 Paper Trail Gem很好地设置了我的基本模型文章,它有一个名为 body
的 text
列。但是,在我实现 Action Text 之后到我的应用程序并从 Article 模型中删除了 body
列,我无法让 Paper Trail 跟踪相关 body
列中的更改。 如何我可以让它工作吗?
免责声明:我是 Rails 的新手。
文章.rb
...
has_rich_text :body
has_paper_trail
...
文章架构(删除 :body 列后)
create_table "articles", force: :cascade do |t|
t.string "title"
t.string "slug"
t.datetime "archived_at"
t.datetime "published_at"
...
end
Action 文本架构
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
我很乐意将与之前相同的功能返回到应用程序,我可以在其中看到文章正文中所做的更改。例如。有人加了一句话,删了一个字等等。
最佳答案
结合对我有用的答案:
# frozen_string_literal: true
ActiveSupport.on_load(:action_text_rich_text) do
ActionText::RichText.class_eval do
has_paper_trail
end
end
在 lib/rich_text_paper_trail.rb
中并确保已加载此文件!例如通过明确要求它:require 'rich_text_paper_trail'
关于ruby-on-rails - 如何让 Paper_trail 与 Action 文本一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55544935/