Home>


I want to implement a login function using devise like the following site.
https://qiita.com/Orangina1050/items/a16e655519a60f35b394


・ I am writing a view layer using slim
・ Bootstrap is installed
-The following command has been executed

$rails g controller comments index
$rails g devise: install
$rails g devise user # Create model for login function
$rake db: migrate
$rails g devise: views

Also, as shown in the code below, the content of link_to is changed in the application.html.slim file depending on whether the user is logged in or not.

doctype html
html
  head
    title
      | Login Devise
    = csrf_meta_tags
    = csp_meta_tag
    = stylesheet_link_tag'application', media:'all','data-turbolinks-track':'reload'
    = javascript_pack_tag'application','data-turbolinks-track':'reload'
  body
    .navbar.navbar-light.bg-light
      .navbar-brand Check login function
      ul.navbar-nav.justify-content-end
        --if user_signed_in?
          li.nav-item = link_to'Change profile', edit_user_registration_path, class:'nav-link'
          li.nav-item = link_to'log out', destroy_user_session_path, class:'nav-link'
        --other
          li.nav-item = link_to'user registration', new_user_registration_path, class:'nav-link'
          li.nav-item = link_to'login', new_user_session_path, class:'nav-link'


When I start the server, the user registration link and login link are displayed in the navigation bar because I have not registered as a user yet, but when I click the user registration link, an error like the attachment is displayed.

Also, even if you log in, the path will change to http: // localhost: 3000/users/sign_in, but the screen will not be the login screen.
(If i look at the article on the above site, it seems that it will be created automatically when you install devise, even if you do not create the login screen or sign-up screen yourself, so if you jump to the link you pushed, the default sign I understood that the page transitions to the up screen or login screen, but is it wrong in the first place?)

How can I resolve the attached error and display the login screen?
Thanks for your understanding.

  • Answer # 1

    I found that the cause was that I slimmed the html file of views/devise without applying bootstrap to devise.

Related articles