I am trying to combine Devise with a RESTful user resource using the following code in the routes.rb file:
resources :users, :only => [:index, :show]
devise_for :users
However the url localhost:3000/users/sign_up does not go to the devise sign up page, rather it produces the error "Couldn't find User with ID=sign_up", so it thinks the url is pointing to the show action of the users controller. I have found that swapping the order of the lines produces the intended behaviour:
devise_for :users
resources :users, :only => [:index, :show]
Now when you go to localhost:3000/users/sign_up you do indeed get the sign-up page, and going to localhost:3000/users/1 hits the show action of the users controller as intended.
My question is this: is changing the code order like this the correct way to get devise working together with the users resource? Or is there something deeper going wrong? I suspect that merely swapping those two lines of code round can't be the solution!