There are times when you have more than one Devise model in one application, and a question comes to your mind, such as "How do I maintain its views so that they will have different views?" Previously, I wrote about generating views, so you can make some custom changes to the views by executing the following command:
$ rails generate devise:views
Now, you are going to learn about how to generate scoped views in Devise. At first, you need to make a little modification to config/initializers/devise.rb
. You need to remove the comment tag for this code:
config.scoped_views = true
This code will enable scoped views for Devise, so you can generate some specific views for your Devise model.
Before we start generating views, let's have two new Devise models for admin
and employee
as the examples. Now, you can generate scoped views for your Devise model by executing this command:
$ rails generate devise:views admins $ rails generate devise:views employees
The following...