2014-11-01 155 views
1

喜我使用积极管理的宝石在我的项目ActiveAdmin注销链接不可见

我看不到主动管理仪表板注销链接。

我只有一个表是用户表的所有用户

的routes.rb

Rails.application.routes.draw do 

     ActiveAdmin.routes(self) 
     devise_for :users, controllers: { sessions: 'sessions' , :registrations => "registrations" } 
     namespace :api do 
     namespace :v1 do 
      resources :users 
     end 
     end 

     resources :users 
     devise_scope :user do 
     match '/users/sign_in', to: 'sessions#create', via: :post 
     #registration seems to much cooler for authenticable and other stuff 
     #match 'api/v1/users' , to: 'registrations#create' , via: :post 
     end 

    end 
在/管理/仪表板

ActiveAdmin.register_page "Dashboard" do 

    menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") } 

    content title: proc{ I18n.t("active_admin.dashboard") } do 
    div class: "blank_slate_container", id: "dashboard_default_message" do 
     span class: "blank_slate" do 
     span I18n.t("active_admin.dashboard_welcome.welcome") 
     small I18n.t("active_admin.dashboard_welcome.call_to_action") 
     end 
    end 
    end # content 
end 

这该怎么我的管理/用户查看像

ActiveAdmin.register User do 
    #permit_params :email , :role_ids ,:password 
    permit_params :email , :password ,:role_ids => [] 

    form do |f| 
    f.inputs "Users" do 
     f.input :email 
     f.input :password 
     f.input :roles, as: :select, multiple: false, collection: Role.all 

    end 
    f.actions 

    end 

    show do 
    attributes_table do 
     row :email 
     row :encrypted_password 
     row :reset_password_token 
     row :reset_password_sent_at 
     row :remember_created_at 
     row :sign_in_count 
     row :current_sign_in_at 
     row :last_sign_in_at 
     row :current_sign_in_ip 
     row :last_sign_in_ip 
     row :created_at 
     row :updated_at 
     row :authentication_token 
     row :roles do | user | 
     user.roles.first.name unless user.roles.blank? 
     end 
    end 
    end 

    index do 
    column :email 
    #column :encrypted_password 
    #column :reset_password_token 
    #column :reset_password_sent_at 
    column :remember_created_at 
    column :sign_in_count 
    column :current_sign_in_at 
    column :last_sign_in_at 
    #column :current_sign_in_ip 
    #column :last_sign_in_ip 
    column :created_at 
    column :updated_at 
    #column :authentication_token 
    column :roles do | user | 
     user.roles.first.name unless user.roles.blank? 
    end 
    actions 
    end 
    controller do 
    def create 
     @user = User.new(user_params) 
     binding.pry 

     add_roles(@user) 
     create! 
    end 

    def update 
     add_roles(resource) 
     update!(user_params) 
    end 

    private 
     def add_roles(resource) 
     resource.roles = [] 
     params[:user][:role_ids].each { 
      |r| resource.add_role(Role.find(r).name.downcase!) unless r.blank? 
     } 
     end 
     def user_params 
     params.require(:user).permit(:email, :password, :role_ids => []) 
     end 
    end 
end 

回答

5

这可能是因为它没有找到注销路径或当前用户。 尝试修改您的active_admin初始值设定项:

config.logout_link_path = :logout_path #Put your logout path here 
config.logout_link_method = :delete 

config.current_user_method = :current_user