在PaperTrail中,如何记录每个版本的评论?
In PaperTrail, how to record a comment with each Version?
我正在构建一个基于 RoR 的 wiki。我们使用 paper_trail gem 来管理文章版本,但是通过 changeset 方法查看文章随时间的变化是一种糟糕的用户体验。
我们想出的最好的主意是在编辑器保存更改之前需要一个 git-commit-message-style 注释。这些提交消息将附加到文章更新时创建的文章版本。
由于版本模型位于 paper_trail gem 中,我不确定如何将版本 table 与我的新 commit_messages table s.t。一个 CommitMessage belongs_to 一个版本。
[I want] to require a git-commit-message-style comment before an editor can save changes
您可以将 comment
列添加到 versions
table。 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 your versions
table.
class ApplicationController
def info_for_paper_trail
{ :ip => request.remote_ip, :user_agent => request.user_agent }
end
end
如果这不起作用,自述文件记录了其他存储元数据的方法。
我正在构建一个基于 RoR 的 wiki。我们使用 paper_trail gem 来管理文章版本,但是通过 changeset 方法查看文章随时间的变化是一种糟糕的用户体验。
我们想出的最好的主意是在编辑器保存更改之前需要一个 git-commit-message-style 注释。这些提交消息将附加到文章更新时创建的文章版本。
由于版本模型位于 paper_trail gem 中,我不确定如何将版本 table 与我的新 commit_messages table s.t。一个 CommitMessage belongs_to 一个版本。
[I want] to require a git-commit-message-style comment before an editor can save changes
您可以将 comment
列添加到 versions
table。 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
如果这不起作用,自述文件记录了其他存储元数据的方法。