我正在创建一个表单供管理员进入并列出、编辑和删除用户。我尝试了许多不同的变体来删除用户,但没有任何效果。我想知道是不是因为我需要在我的routes.rb中使用devise_for :users
and 。resources :users
这是因为我有链接到用户的上传/附件。但这是我的链接
<%= link_to 'Delete',user, :method => 'delete', :confirm => 'Are you sure?' %>
还有我的 routes.rb
# devise_for :users
devise_for :users do
get "/users/sign_out" => "devise/sessions#destroy", :as => :destroy_user_session
end
resources :users do
resources :attachments
end
我收到的错误是The action 'destroy' could not be found for UsersController.
但是我的用户控制器有
def destroy
@user = User.find(params[:id]).destroy
redirect_to admin_index, :flash => { :success => 'User was successfully deleted.' }
end