I just disabled using default layout by adding layout false
in devise session controller and everything works fine now. Thanks!
current_page? method causes error 500 when used with rails_admin and devise
-
01-07-2022 - |
Question
I try to use current_page? method in my navbar this way:
<ul class="nav pull-right">
<li class="<%="active" if current_page?(controller: :welcome)%>"><%= link_to "Home", "/"%></li>
<li class="<%="active" if current_page?(controller: :products)%>"><%= link_to "Store", "/products"%></li>
<li class="<%="active" if current_page?(controller: :catalog)%>"><%= link_to "Catalog", "/catalog"%></li>
...
Everything works fine when I move between pages.
But when I try to go to /admin
which is provided by rails_admin I get 500 internal server error in response. This is probably caused by current_page? method because if I remove them from layout everything works fine.
I'll appreciate any solution.
Solution 2
OTHER TIPS
In case anyone runs into this and wants to fix it, you need to use absolute urls in the way you pass parameters to current_page?
So in your case, this code will work:
<ul class="nav pull-right">
<li class="<%="active" if current_page?(controller: '/welcome')%>"><%= link_to "Home", "/"%></li>
<li class="<%="active" if current_page?(controller: '/products')%>"><%= link_to "Store", "/products"%></li>
<li class="<%="active" if current_page?(controller: '/catalog'')%>"><%= link_to "Catalog", "/catalog"%></li>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow