获取Paper_trail + Rails_admin +具有多个“用户”模型的设计 [英] Getting Paper_trail + Rails_admin + Devise with Multiple 'user' models

查看:198
本文介绍了获取Paper_trail + Rails_admin +具有多个“用户”模型的设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Rails 3开发一个应用程序,目前我使用Devise作为登录,Rails_admin作为管理面板,Paper_trail跟踪用户模型所做的所有更改...问题是我有两个用户模型,用户和管理员。因此,rails_admin.rb(initiliazer)中的一行代码设置Paper_trail来跟踪历史记录:

  config.audit_with:paper_trail,User 

有没有办法让用户和管理员进行paper_trail监视更改,它只跟随一个模型?我注意到,即使这样设置,并且我作为管理员从Rails_admin内进行更改,更改说明是由用户与管理员相同的ID进行的做出改变。

解决方案

处理这个的最好方法是安装CanCan,删除我的管理模型,并利用针对当前情况,单个模型中的多个角色。


I am developing an app in Rails 3, currently I use Devise as the login and Rails_admin as the admin panel with Paper_trail tracking all changes made by 'user' model... Problem is I have two user models, User and Admin. So a line of code in rails_admin.rb (initiliazer) to setup Paper_trail to track history:

  config.audit_with :paper_trail, User

Is there any way to have paper_trail monitor changes made by both User and Admin, or can it only follow one model? I notice that even when it is set like this, and I make a change from within Rails_admin as an admin, the change says it was made by the User with the same ID as the admin that made the change.

解决方案

The best way to handle this is to install CanCan, remove my Admin Model, and take advantage of using Multiple Roles within a single model for the current situation.

这篇关于获取Paper_trail + Rails_admin +具有多个“用户”模型的设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆