Ruby On Rails: Devise Setup Tip

Josh burger
3 min readMar 24, 2021


Hello, Back again for the phase 3 project, and this time around, I made a list/task manager. I had a good experience with this project. One of the requirements was to make a login on my site, Which would allow a user to log in through Facebook and keep their email and password the same as Facebook. My users also have the option to signup through my website as well. Working on this project I ran into a small problem, But a very good problem at the same time. With the Devise views, you can have an issue and ill explain how to fix it.

I went and created the link using Devise/Omniauth. This blog will only be talking about Devise. If you get the gem “Devise” and bundle install, Then generate the Devise views [$ rails generate devise: views] that will give you a bunch of folders with views. Within the View, Users folder you will have a folder called shared and within there you will have a _link partial. The partial looks like this:

The button_to in this file is normally link_to, but in my project, I was having an issue with them using omniauth. I changed them to the button_to, In the process of trying to change anything within the links, nothing would change visually no matter what I tried. Which was really weird. I spent a good 2 hours trying to figure out why the link would always stay no matter what I changed. This is when I found out about devise scoped_views.

The picture above is commented out normally when you load the devise initializer's devise.rb file. I found some information reading the devise docs which lead me and another cohort teacher to figure out the problem. Devise offers an easy way to customize views. All you need to do is set config.scoped_views = true inside the config/initializers/devise.rb file. After doing so, you will be able to have views based on the role like users/sessions/new and admins/sessions/new. If no view is found within the scope, Devise will use the default view at devise/sessions/new.


I hope this helped if you had trouble with Devise views, I know it helped me that's why I had to make a blog on the topic.