简体   繁体   English

如何使用rails_admin gem创建两个管理员视图并在两个管理员视图之间分离模型

[英]How to create two admin view and separating the model between 2 admin views by using rails_admin gem

I want to create two admin views by using rails_admin gem. 我想使用rails_admin gem创建两个管理员视图。 I created one admin and i specify the path( mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' in routes.rb) . 我创建了一个管理员,并指定了path( mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' in routes.rb)

Similarly I specified another path (mount RailsAdmin::Engine => '/superadmin', :as => 'superadmin' ) . 同样,我指定了另一个path (mount RailsAdmin::Engine => '/superadmin', :as => 'superadmin' )

Now I am getting the same views for both superadmin and admin view. 现在,超级管理员和管理员视图都具有相同的视图。 I used devise and cancan for authentication. 我使用了devise和cancan进行身份验证。

But I want to seperate the model in 2 views. 但是我想在2个视图中分离模型。 I don't know where to make changes. 我不知道在哪里进行更改。
In config/initializers/rails_admin.rb I included some models but it is reflected in both admin views. config/initializers/rails_admin.rb我包括了一些模型,但这在两个管理员视图中都得到了体现。

How to accomplish this? 如何做到这一点?

You cant achieve that using rails_admin . 您无法使用rails_admin实现这一rails_admin I've tried couple of months ago and found its not made for that. 我已经尝试了几个月,却发现它不是为此而设计的。

Currently I am using rails_admin for SuperAdmin as its required less customization. 目前,我正在使用用于SuperAdmin的rails_admin,因为它所需的定制较少。

And

I am using active_admin for normal administration. 我正在使用active_admin进行常规管理。

Rails admin lets you customize stuff by user but you'll have to do a tedious configuration for all your models. Rails管理员允许您按用户自定义内容,但是您必须对所有模型进行繁琐的配置。 If you want super fine grained customization. 如果您想要超细粒度的自定义。 For example 例如

edit do
  field :avatar do
    visible do
      bindings[:view]._current_user.id
    end
  end
end

You can always use cancancan and customize your can read permissions depending on the type of user, rails_admin will honor them. 您始终可以使用cancancan并根据用户类型自定义您的can读取权限,rails_admin将兑现它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM