我正在构建一个基于 RoR 的 wiki。我们使用 paper_trail gem 来管理文章版本,但是通过变更集方法查看文章随时间的变化是一种糟糕的用户体验。
我们提出的最好的想法是在编辑器保存更改之前需要 git-commit-message-style 注释。这些提交消息将附加到更新文章时创建的文章版本。
由于 Version 模型位于 paper_trail gem 中,我不确定如何将 Versions 表与我的新 commit_messages 表关联起来。 CommitMessage 属于_版本。
最佳答案
[I want] to require a git-commit-message-style comment before an editor can save changes
您可以将comment
列添加到您的versions
表中。 PaperTrail 将此称为 "Storing Metadata" .
Metadata from Controllers
You can also store any information you like from your controller. Override the
info_for_paper_trail
method in your controller to return a hash whose keys correspond to columns in yourversions
table.class ApplicationController def info_for_paper_trail { :ip => request.remote_ip, :user_agent => request.user_agent } end end
如果这不起作用,自述文件记录了存储元数据的其他方法。
关于ruby-on-rails - 在PaperTrail中,如何记录每个版本的评论?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36168574/