ruby - Trying to access current user's role -
i need access current users role in order make sure admin. if admin want display following link in view.
<% if current_user.role =='admin' %> <li class="manage"> <a href="#" id="manage" style="float:none;"> manage </a> </li> <% end %>
my problem in controller (below). how define @user aligns current user? right getting "couldn't find user without id" error
def index @user = user.find(params[:id]) respond_to |format| format.html end
why want align @user , current_user? 2 different things.
- current_user user logged in (identified , authenticated). using devise or authentication gem?
- @user typically user you're trying edit, or display, determined params[:id]. resource you're trying access. begs question; @user mean you?
Comments
Post a Comment