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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -