Customizing View Representation in Rails

I use devess for the auth user, but I have good layouts for registration, login, etc. I have already rails generate devise:views User command and have all the views in the views folder, however, when I replaced register / new.html.erb with my own new.html.erb, nothing changes or looks different. It's like I did something.

Does anyone know what I'm doing wrong, or at least how to successfully set up design views

PS Is it important to note that I changed the development / registration route # new to / signup?

+58
ruby-on-rails views devise
Jul 11 '11 at 7:11
source share
8 answers

Your signup or devise/registrations#new route will display views/devise/registrations/new.html.erb . It looks like you did it changes to views/user/registrations/new.html.erb , which explains why you do not see the changes made since they were not visualized.

You will need to create user/registrations_controller.rb , which extends from Devise::RegistrationsController and points your /signup route to user/registrations#new , or you can just make changes directly to views/devise/registrations/new.html.erb

The same applies to your login pages ( devise/sessions ).

Hope this helps.

+25
Jul 11 '11 at 7:52
source share
β€” -

at first sight.

... instead

 rails generate devise:views User 

Using:

 rails generate devise:views 

If you have already done this, move the created directory from app/views/User to the new app/views/devise (or just rename the User folder to devise if this is an option.)

These folders:

 app/views/User/confirmations app/views/User/mailer app/views/User/passwords app/views/User/registrations app/views/User/sessions app/views/User/shared app/views/User/unlocks 

No other changes are required.

+98
Feb 17 '13 at 1:59
source share

although this is an old question, I thought I would add to it if someone stumbles upon it. I'm not sure if this is a new addition, since the question was originally asked, but if so, then a (more modern) approach is simpler.

in the config/initializers/devise.rb there is the following code block:

 # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It turned off by default because it slower if you # are using only default views. # config.scoped_views = false 

uncommenting config.scoped_views = false and changing its value to true , the program will automatically check if the user view exists, and if so, then this is necessary. As they say, this adds some overhead to the application, but in my experience this is still minimal.

+90
Mar 24 '13 at 17:23
source share

For anyone who has problems with this, the problem is calling rails generate devise:views User . This should be rails generate devise:views to retrieve the current views from the Engine Engine. This will create the correct views that will work with default routes.

+22
Jun 13 2018-12-12T00:
source share

After creating custom views, for example

 rails generate devise:views User 

Include scoped_views in config/initializer/devise.rb

 view config.scoped_views = true 

And you're done.

+15
Jun 10 '15 at 13:38
source share

Using rails g devise:views User allows you to configure when you have more than one role.

the correct way to do this goes into your devise.rb folder in config/initializer/

and uncommenting and setting config.scoped_views = true .

Now you can edit erb files without any problems.

+9
Feb 08 '13 at 6:42
source share

I had the same problem until I came back and read the development documentation :)

After rails generate devise:views make sure you go into initializers/devise.rb and set config.scoped_views = true . This is explained in the https://github.com/plataformatec/devise development documentation, as well as in the devise.rb comments.

After that, my own views in views/users began to appear instead of those in the gem.

+8
Sep 13 '14 at 18:50
source share

For future reference, you can simply rename the folder from devise => user and vice versa, and the rails will find the route.

+2
May 26 '13 at
source share



All Articles