2016-10-29 77 views
0

嘿我試圖摧毀一個用devise創建的用戶。設計破壞用戶 - 未初始化的常量User :: Profile

這裏是我的文件:

users_controller.rb

before_action :find_user 
def destroy 
    @user.destroy 
    if @user.destroy 
     redirect_to admin_users_path, notice: "User destroyed" 
    end 
end 

的routes.rb

devise_for :users 
match 'users/:id' => 'users#destroy', :via => :delete, :as => :admin_destroy_user 

觀點:

= link_to "delete", admin_destroy_user_path(u), method: :delete, data: {confirm: "You sure?"} 

,但我得到以下錯誤消息:

NameError in UsersController#destroy 
uninitialized constant User::Profile 
+0

顯示控制器,你使用參考'Profile'或'用戶:: Profile' –

回答

0

試試這個:

before_action :find_user 
def destroy 
    if @user.destroy # in this place you will destroy your user 
     redirect_to admin_users_path, notice: "User destroyed" 
    end 
end 
+0

其中的一部分,我得到同樣的錯誤 – Max

相關問題