I have 2 models:
- Users
- Suppliers
and I want to provide 2 isolated Active Admin interfaces. They both have devise routes:
devise_for :users, ActiveAdmin::Devise.config
devise_for :suppliers, ActiveAdmin::Devise.config (can I somehow say ActiveAdmin2::Devise.config)
User will have access to Products, Orders and Supplier will have access to products only.
Ideally, I want to have different Folders in the app and present different data.
user/order.rb
ActiveAdmin.register Order do
filter :email
filter :created_at , :label => "Order Creation Date"
filter :order_created
supplier/order.rb
ActiveAdmin.register Order do
filter :email
Is there any way to initialize 2 ActiveAdmin Classes and run them in parallel?
Any other better way to make it work under the same website/app?
You can use namespaces for this.
ActiveAdmin.register Order, namespace: :supplier do # will be available at /supplier/orders end ActiveAdmin.register Order, namespace: :user do # available at /user/orders end
You can customize the authentication for each namespace in config/initializers/active_admin.rb
For example:
config.default_namespace = :user config.namespace :supplier do |supplier| supplier.authentication_method = :authenticate_supplier_user! supplier.current_user_method = :current_supplier_user supplier.logout_link_path = :destroy_supplier_user_session_path supplier.root_to = 'orders#index' end config.namespace :user do |user| user.authentication_method = false user.current_user_method = :current_user user.logout_link_path = false
More info on: http://activeadmin.info/docs/1-general-configuration.html#namespaces
来源:https://stackoverflow.com/questions/12386535/how-to-use-multiple-active-admin-instances-for-complete-separate-models