0

All, i am facing an issue with routing when i click on the link i am taking to a blank page and only when i click refersh in my browser am i taking to the re-directed page.

In my Navbar App: enter image description here

  <%= link_to "Sign up", new_user_registration_path, class: "dropdown-item"  %>
              
  <div class="dropdown-divider"></div>
  <%= link_to "Login", new_user_session_path, class: "dropdown-item"   %>

Routes devise_for :users

If i click on login i am taking to a blank page

enter image description here

If i hard refresh (F5) I am redirected. This i am using devise Gem

enter image description here

Any pointers will be helpful.. Thanks in advance...

  • Strange. Please remove class: 'dropdown-item', maybe bootstrap interferes with it. If not. check your Network tab in the browser console and see what request it does. – razvans Feb 20 '21 at 22:36
  • Do you have turbolinks enabled? – razvans Feb 21 '21 at 07:03
  • I've had this issue in the past with Turbolinks, can you try adding this to the `sessions/new` view and see if it works? `<% content_for :head do %> <% end %>` You'll also need to add `yield(:head)` to your layout file before the end of ``. –  Feb 21 '21 at 11:34
  • The first page seems not to be empty. It displays the text "2021". – Jussi Hirvi Feb 21 '21 at 16:17
  • I have tried this but this didn't work. The problem i found out is that because its custom boostrap, i had my partial header and footer and the html on the page itself reference footer and other had header, hence it just redirect with 2021 but i had to refresh to be routed to the page. – Randy mangal Feb 22 '21 at 00:37

2 Answers2

0

You aren't redirected after you hit refresh. Devise routes work fine because you land on the correct URL users\sign_in after you click the login link. So the reason your page is not loading is not Devise but something on the login page that prevents it from rendering. Opening the browser console and checking for JS errors might give you some hints.

inmydelorean
  • 448
  • 6
  • 13
  • i do see this warningThe resource https://demoproject-randi2160920490.codeanyapp.com/assets/application.debug-9e0f6944a9ad6740ae459231ca3193aa78b69acfadaafaba30023b6e8169f7ba.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally. – Randy mangal Feb 21 '21 at 11:16
  • @Randymangal You are working with a custom bootstrap template and copying the HTML from the template and paste it into your existing pages together with head and body sections. Look at your HTML structure, you have a soup of multiple `head` and `body` sections. You are supposed to have one for each. Rework your page structure so that it has the correct HTML structure and only loads the assets that you need. https://www.w3schools.com/html/html_intro.asp – inmydelorean Feb 21 '21 at 14:26
  • Great Pointer, it was because i do have more than one footer and body within the page and the Application html.erb file Thank you – Randy mangal Feb 22 '21 at 00:35
0

I had exactly the same issue. For my project I used some bootstrap template and it had this js code in the footer:

<script>document.write(new Date().getFullYear())</script> 

Every time I click a turbo link, the content of page was replaced with a current year - 2022. (2021 in your case)

Abliamit
  • 483
  • 1
  • 3
  • 13