The second development model does not use generated views

I have a User model and Rep

devise_for :users, :controllers => {:registrations => 'user_registration'} devise_for :reps 

I ran

 rails generate devise:views reps 

Custom views are displayed in application / views / repeats

But rep paths still use inline views

Rendered ~ / .rvm / gems / ruby-1.9.2-p290 / gems / devise-1.4.9 / app / views / devise / registrations / edit.html.erb

Instead of created reps views.

+4
source share
3 answers

By simply posting the views there, Devise will not use them. You will need to point the Devise::RegistrationsController to the right controller that has these views, what you can do by calling this:

  devise_for :reps, :controllers => { :registrations => "reps/registrations" } 

To do this, there must be a new controller defined in app/controllers/reps/registrations_controller.rb :

  class Reps::RegistrationsController < Devise::RegistrationsController end 

Then you will have views in the correct directory for use by this controller.

+8
source

I had the same problem. In the end, I noticed this in the documentation.

If you have several roles in your application (for example, "User" and "Administrator"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you have to do is set "config.scoped_views = true" inside "config / initializers / devise.rb".

So, I switched the config.scoped_views parameters to true, and this worked:

+26
source

I had the same problem, and I realized that model names are case sensitive. I used the command

 rails generate devise:views Admins 

Instead

 rails generate devise:views Admins 

and he created a folder in '/ app / views / Admins', but looked for a custom view in 'app / views / admins'

0
source

Source: https://habr.com/ru/post/1383784/


All Articles