Tôi có ActiveAdmin và Devise làm việc với Người dùng. Tôi muốn sử dụng Devise để đăng nhập người dùng không phải quản trị viên thông thường bằng cùng một mô hình Người dùng. Tôi có thể làm cái này như thế nào? (Tôi muốn có một lá cờ admin
trong mô hình tài khoản cho quản trị viên mà thôi.) Tôi đã thử thêm dòng thứ 2 để routes.rbLàm cách nào để sử dụng Devise và ActiveAdmin cho cùng một Mô hình người dùng?
devise_for :users, ActiveAdmin::Devise.config
devise_for :users
Nhưng nó đã cho một lỗi khi tôi đã cố gắng để liệt kê các tuyến đường
>rake routes
DL is deprecated, please use Fiddle
rake aborted!
ArgumentError: Invalid route name, already in use: 'new_user_session'
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
Tôi đã tạo bộ điều hợp ủy quyền chỉ kiểm tra user.admin == true
và đang hoạt động OK cho ActiveAdmin. https://github.com/activeadmin/activeadmin/blob/master/docs/13-authorization-adapter.md
Câu trả lời tuyệt vời .. Thực sự rất hữu ích. – SSR