ruby on rails 4 - ActionController::UrlGenerationError in Devise::Sessions#new -
i use nav bar (using devise on rails; included in dashboard.html.erb) works fine when logged in; when wanting use in pages , including in application.html.erb, error: actioncontroller::urlgenerationerror in devise::sessions#new
additional info: "no route matches {:action=>"index", :controller=>"devise/users"}"
this route.rb:
rails.application.routes.draw root 'dashboard#index' devise_for :users resources :users
how should implement in rails following dry? (am new rails)
this navigation bar:
<nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand"><%= rails.application.class.parent_name %></a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li><%= link_to 'dashboard', root_path %></li> <li><%= link_to 'users', controller: 'users' %></li> <li><a href="#contact">contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><p> logged in <%= current_user.email %></p></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li role="separator" class="divider"></li> <li class="dropdown-header">nav header</li> <li><a href="#">separated link</a></li> <li><a href="#">one more separated link</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><%= link_to "log out", destroy_user_session_path, method: :delete %></li> <li><%= link_to edit_user_registration_path %><strong><%= current_user.first_name %></strong><% end %></li> </ul> </div><!--/.nav-collapse --> </div>
i assume you're using wrong arguments link_to
helper here:
<li><%= link_to 'users', controller: 'users' %></li>
try one:
<li><%= link_to 'users', users_path %></li>
or, if point actual controller:
<li><%= link_to 'users', controller: 'users', action: 'index' %></li>
more info link_to
available here
hope helps.
update
yes, sure, can next:
<% if user_signed_in? %> <ul class="nav navbar-nav"> <li><%= link_to 'dashboard', root_path %></li> <li><%= link_to 'users', controller: 'users' %></li> <li><a href="#contact">contact</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">dropdown <span class="caret"></span></a> <ul class="dropdown-menu"> <li><p> logged in <%= current_user.email %></p></li> <li><a href="#">another action</a></li> <li><a href="#">something else here</a></li> <li role="separator" class="divider"></li> <li class="dropdown-header">nav header</li> <li><a href="#">separated link</a></li> <li><a href="#">one more separated link</a></li> </ul> </li> </ul> <% else %> # somethid else <% end %>
Comments
Post a Comment