我有一个 Rails 3.2.14 应用程序,它有一个Call
具有许多不同关联的模型。我希望能够跟踪Call
模型的更改并以某种方式在Call
Show View 中显示更改列表。
我一直在阅读有关经过审核的gem,它看起来可能会奏效。但在我深入研究之前,我想知道以下内容。
如何从显示视图中调用审核?我假设我可以做一些事情,比如传递一个块:
<% @call.audits.each do |a| %>
<%= a.action %> <%= a.audited_changes %>
<% end %>
当我需要查看为特定呼叫所做的更改时,类似的东西会在显示视图中起作用吗?
宝石如何audited
处理关联,尤其是has_many_through
?
我希望尽快实现此功能,但不想在我的应用程序中引入任何问题。我认为在开发环境中安装可能是最好的途径?
如果有人对此宝石有经验或可以帮助提供答案,我将不胜感激。
更新
所以我尝试安装审核的 gem,我能够显示审核操作和 audited_changes。但是audited_changes的格式是一个序列化的hash。我怎样才能反序列化它并使字段友好?has_many_through
此外,在使用关系/连接表时,gem 似乎没有记录更改。所以我现在拥有的是一个半工作的审计 gem,其中的数据对用户不友好。有什么方法可以美化它并使其对用户有意义?
call.rb 摘录
has_many :call_units
has_many :units, through: :call_units
belongs_to :nature
belongs_to :service_level
belongs_to :patient_sex
belongs_to :insurance
belongs_to :region
has_many :call_special_equipments
has_many :special_equipments, :through => :call_special_equipments
belongs_to :transferred_from, :foreign_key => :transfer_from_id, :class_name => 'Facility'
belongs_to :transferred_to, :foreign_key => :transfer_to_id, :class_name => 'Facility'
belongs_to :parent_call, class_name: "Call"
has_many :notes
belongs_to :cancel_reason