Rails撤消视图中的链接以查看Audited中的更改

时间:2018-04-03 08:03:59

标签: ruby-on-rails ruby undo-redo

当我将以下代码添加到lib

https://github.com/collectiveidea/audited/pull/381/files

我不知道如何在视野中打电话。你能告诉我如何称呼这种方法吗?

我在考虑http://github.com/airblade/paper_trail,但我不想拥有很多宝石。

1 个答案:

答案 0 :(得分:0)

1.创建撤消链接操作的URL /路由

的routes.rb

get 'undo', to: 'audit#undo'

2.创建其控制器/动作

audit_controller.rb

def undo
  current_user.audits.last.undo
end

3.在视图中添加撤消链接

your_view.html.erb

<a href="/undo"></a>