我用我的基本模型文章很好地设置了纸迹宝石,其中有一个名为body的text列。但是,在我将行动文本实现到我的应用程序并将列body从文章模型中删除之后,无法让纸质路径跟踪相关的专栏中的更改。,如何让它工作呢?
免责声明:我是Rails的新手。
Article.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动作文本模式
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我很想把和以前一样的功能返回给应用程序,在这里我可以看到文章正文中所做的更改。有人加了一个句子,删除了一个词,等等。
发布于 2019-05-12 19:58:39
在尝试了这里提供的所有选项之后,我有了一个解决办法的想法--最终效果很好。
我所做的是,我只是用纯 Trix编辑器 版本替换了Action文本,因此我能够将:body保留在自己的article.rb模型中,保存整个对象的版本并显示差异。耶!
发布于 2020-04-29 10:32:25
把答案结合起来对我来说是有效的:
# 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'
发布于 2019-05-08 12:47:57
尝试使用以下内容添加一个config/initializers/rich_text_paper_trail.rb文件:
ActiveSupport.on_load(:action_text_rich_text) do
has_paper_trail
endhttps://stackoverflow.com/questions/55544935
复制相似问题