我目前正在使用https://github.com/thoughtbot/clearance 进行身份验证。
它允许我使用密码和电子邮件注册和登录。
但我想知道如何将其配置为生成用户模型的 CRUD 页面,因为我实际上想查看注册用户列表。
我目前正在使用https://github.com/thoughtbot/clearance 进行身份验证。
它允许我使用密码和电子邮件注册和登录。
但我想知道如何将其配置为生成用户模型的 CRUD 页面,因为我实际上想查看注册用户列表。
您可以使用从间隙子类化的常规用户控制器。
class UsersController < Clearance::UsersController
def index
@logged_in_users = User.where(blah) #whatever logic you need to retrieve the list of users
end
end
我首先创建了我的用户控制器,然后运行了间隙生成器,然后是路由生成器。生成默认路由后,可以修改为指向自己的控制器。
rails g clearance:install
rails g clearance:routes
resources :users, controller: "users" do
resource :password,
controller: "clearance/passwords",
only: [:create, :edit, :update]
end
get "/sign_in" => "clearance/sessions#new", as: "sign_in"
delete "/sign_out" => "clearance/sessions#destroy", as: "sign_out"
get "/sign_up" => "clearance/users#new", as: "sign_up"