I have devise set-up, and it works great when a new user is going through the registration process themselves but before implementing Devise, admin had the ability to create users and behavior related to that was in my old users controller. Now that I am using devise when I visit my old forms, new action triggers fine but when I actually submit the form, no matter what I do it goes to the Devise’s registration controller create action. I know that I can override the controller and copy the code that I had in my old users controller there but I was wondering if there was a way to prevent this behavior on certain calls?
I have tried specifying the controller and the action for the form specifically and it did nothing.
Here are the two relevant paths as defined in my routes:
POST /users(.:format) users#create
user_registration POST /users(.:format) users/registrations#create
Am I going about this wrong?
Usually, I’ll create a separate controller for admin CRUD related to users when I’m using devise. Something like:
I find separating it all makes it more maintainable and makes for less headaches.
Update:
Devise adds it own routes and route helpers, so your user_registration_path and POST /users are being superseded by the routes given in devise, which in this case is also a POST to /users. You can find the source for these routes on github: https://github.com/plataformatec/devise/blob/master/lib/devise/rails/routes.rb
A side note: the two paths that you referenced in your question are the same thing, just the second one will be accessible through a route helper, ie user_registration_path or user_registration_url and the other most be referenced directly.