Devise: Customize controller and views

Devise uses built-in controllers and views by default. If you want to customize them, you have to add them to your rails application.

Assume you have a customer login.

Customizing the controller

Create a new controller at Rails.root/app/controllers/customers/sessions_controller.rb:

class Customers::SessionsController < Devise::SessionsController

Customize your Rails.root/config.routes.rb to use the controller:

devise_for :customers, :controllers => { :sessions => "customers/sessions" }

Customizing the views

First you'll have to add support for scoped views. Uncomment following lines in your Rails.root/config/initializers/devise.rb:

Devise.setup do |config|
  config.scoped_views = true

Then generate the views:

rails generate devise:views customers