Skip to content

Tool: Generate and customize controllers

Maud de Vries edited this page May 10, 2018 · 10 revisions

The easiest way to do this is with the built in generator. An example is:

# Generate all the controllers and specify the 'scope', for example 'users':
$ rails generate devise:controllers users  # `/controllers/users/`

# Generate a controller for one or more modules with the -c flag
$ rails g devise:controllers users -c=registrations #=>  `/controllers/users/registrations_controller`.rb`

And add the controllers to the devise_for routes:
For example:
devise_for :users, controllers: { registrations: 'users/registrations' }

See Readme for similar options for the views.

Clone this wiki locally