I have added a field to the sign-up form that is based on a different model, see How do I use nested attributes with the devise model for the gory details. This part is work
A better and more organized way of overriding Devise controllers and views using namespaces:
Create the following folders:
app/controllers/my_devise
app/views/my_devise
Put all controllers that you want to override into app/controllers/my_devise and add MyDevise
namespace to controller class names. Registrations
example:
# app/controllers/my_devise/registrations_controller.rb
class MyDevise::RegistrationsController < Devise::RegistrationsController
...
def create
# add custom create logic here
end
...
end
Change your routes accordingly:
devise_for :users,
:controllers => {
:registrations => 'my_devise/registrations',
# ...
}
Copy all required views into app/views/my_devise
from Devise gem folder or use rails generate devise:views
, delete the views you are not overriding and rename devise
folder to my_devise
.
This way you will have everything neatly organized in two folders.