ruby on rails 3 - Log In - if Admin direct to Admin Index 1st -
i have 'user' log-ins set , working. change when admin or moderator logs in - directed /admin/index page 1st can preview new posts?
would add 'home' link 'users' sit neatly beside 'sign in' , 'sign up' links, not sure how in code block?
any code solutions appreciated...
views/layouts/application.html.erb <div id="user_nav"> <% if user_signed_in? %> signed in <%= current_user.email %>. not you? <%= link_to "sign out", destroy_user_session_path %> <% else %> <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %> <% end %> </div>
you can add home link before or after if/else/end block:
<div id="user_nav"> <%= link_to "home", root_path %> <% if user_signed_in? %> signed in <%= current_user.email %>. not you? <%= link_to "sign out", destroy_user_session_path %> <% else %> <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %> <% end %> </div>
or
<div id="user_nav"> <% if user_signed_in? %> signed in <%= current_user.email %>. not you? <%= link_to "sign out", destroy_user_session_path %> <% else %> <%= link_to "sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %> <% end %> <%= link_to "home", root_path %> </div>
as directing admin or moderator different page on signup, detect user's role in controller handles new_user_session_path
, redirect_to /admin/index
if type of user.
Comments
Post a Comment