如何将 CanCan 与 Rails admin 一起使用来检查所有权
当我的应用程序中的用户不是管理员用户时,我只想让他们看到他们拥有所有权的字段。
是否有一个如此设置的 can :see
或类似的内容,以便它只显示使用“可以看到”的字段,或者我应该有一个名为 can 的能力:oversee
表示他们可以看到所有内容。
我想检查用户是否是rails admin中的管理员要容易得多,因此将rails admin设置为仅提取当前用户的记录。
When a user in my app isn't an admin user i want to only let them see the fields that they have ownership of.
Is there a so set can :see
or something like that on a per field basis so that it displays just the fields that that use "can see", or should I have an ability called can :oversee
to state that they can see everything instead.
I suppose it's much easier to just check if the user is admin or not in rails admin, so where set rails admin to only pull the current user's records.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用cancan,您可以像这样检查对象的权限:
但这仅指对象级别的可见性。
在 RailsAdmin 中,您可以通过传入块来设置字段可见性,如此处所述。
例如:
With cancan, you can check permissions on objects like this:
But that's only referring to visibility at the object level.
In RailsAdmin, you can set field visibility by passing in a blocks, described here.
For example: