paper_trail非常适合我们。但是当我们登录到 Heroku 的控制台heroku run console
然后我们进行更改时,更改的发起者没有设置:(。所以 paper_trail 有一个机制:
In a console session you can manually set who is responsible like this:
>> PaperTrail.whodunnit = 'Andy Stewart'
>> widget.update_attributes :name => 'Wibble'
>> widget.versions.last.whodunnit # Andy Stewart
You can avoid having to do this manually by setting your initializer to pick up the username of the current user from the OS, like this:
<bunch of code>
我的问题是我们如何使用 Heroku 实现自动化?有没有这样的事情我可以做?
heroku run console -e "PaperTrail.whodunnit = '123:console'"
然后我们每个人都可以使用我们各自的用户 ID 简单地创建一个console.sh
包含上述内容的文件。或者是否有另一种机制可以自动执行此操作?