I'm working with devise for authentication. My issue comes along when trying to delete a user. I get the following ActiveRecord::RecordNotFound Error Couldn't find User with id=users
The error is hitting at:
before_filter :authenticate_user!, :except => [:show]
def show
@user = User.find(params[:id])
end
and the parameters being passed are:
{"controller"=>"users", "action"=>"show", "id"=>"users"}
I have been wondering if this error is related to the class RegistrationsController < Devise::RegistrationsController I've created for devise customization, but I'm not sure.
My gut is telling me that this really is a routing issue. Here is my routes file:
Music::Application.routes.draw do
# resources :users
devise_scope :user do
get "/edit/account/:id" , to: "devise/registrations#edit" , :as => "edit_account"
get "/login" , to: "devise/sessions#new" , :as => "login"
get "/logout" , to: "devise/sessions#destroy" , :as => "logout"
end
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "registrations" }
resources :contact_us_emails
get('/about-us', { :controller => "WelcomePages", :action => 'about', :as => 'about_us'})
get('/contact_us', { :controller => "WelcomePages", :action => 'contact_us', :as => 'contact_us'})
get('/search_collaborators', { :controller => "SongRooms", :action => 'search_collaborators', :as => 'search_collaborators'})
resources :searches do
collection do
get '/song_rooms/:query', :controller => "searches", :action => 'song_rooms', :as => 'search_song_rooms'
get '/users/:query', :controller => "searches", :action => 'users', :as => 'search_users'
get '/final_songs/:query', :controller => "searches", :action => 'final_songs', :as => 'search_final_songs'
get '/search_and_invite_facebok_friends/:user_id', :controller => "searches", :action => "search_and_invite_facebok_friends", :as => 'invite_fb_friends'
end
end
match 'download/:id' => 'versions#download', :as => :download
match '/musicians' => 'searches#musicians', :via => :get, :as => 'musicians'
match '/producers' => 'searches#producers', :via => :get, :as => 'producers'
match '/accept/:id' => 'requests#accept', :via => :get, :as => 'accept'
match '/deny/:id' => 'requests#deny', :via => :get, :as => 'deny'
match '/users/:id' => 'devise/registrations#destroy', :via => :delete, :as => 'cancel_registration'
resources :versions do
resources :messages
member do
post :vote
get :mark_as_final
get :unmark_as_final
end
end
post('/collaborators', {:controller => "Collaborators", :action => 'create', :as => 'create_collaborator'})
delete('song_rooms/:id/collaborators/:id', { :controller => "Collaborators", :action => 'destroy', :as => 'delete_collaborator'})
resources :song_rooms do
member do
get 'choose_final_song'
end
resources :collaborators
end
resources :user_song_uploads
# resources :users
post('/user/:id/vote', { :controller => "Users", :action => 'vote', :as => 'user_vote'})
match '/:id', :to => "users#show", :as => :user, :via => :get
authenticated :user do
root :to => "welcome_pages#home" , :as => "user_home"
end
root :to => "welcome_pages#index" , :as => "home"
end
Finally my cancel link_to action is this:
<%= link_to "Cancel my account", registration_path(resource), :data => { :confirm => "Are you sure?" }, :method => :delete %>
I've also tried switching out resource for resource_name, @user, @user.id, current_user, current_user.id.
Thanks for any help!!