Reputation: 48483
I am using Devise and when I check the form for registration of the new user, in the method is set up just this: /users
.
When I check in logs where the app goes after hitting submit button in the registration form, it's here:
Started POST "/users" for 127.0.0.1 at 2013-08-21 18:13:11 +0200
Processing by Devise::RegistrationsController#create as HTML
But when I go to the Registration Controller
and there to the action create
and comment all code in there, there is no error, everything is processed correctly, which makes me confused.
Where is the code for creating a new user for Devise gem?
Upvotes: 0
Views: 1637
Reputation: 24815
Your custom RegistrationController is built for overwrite the original one when needed.
If you remove all custom code, the original controller in gem will be called. It has already been included into app when loading.
Here is the code for original one: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
To correctly overwrite, you need to specify it in routes.rb.
devise_for :users, :controllers => { registrations: 'users/registrations',
sessions: 'users/sessions' }
Then, create file app/controllers/users/registrations_controller.rb
.
Then, name this class with namespace as defined in routes, and inherit it from original controller
class Users::RegistrationController < Devise::RegistrationsController
def create
if foo == bar
# your logic
else
super # Call original method
end
end
end
Upvotes: 1