2012-07-24 46 views
0

我希望在登錄時能夠用我的導航欄上的用戶名替換帳戶選項卡。我該如何去做。我會必須使用某種嵌入式紅寶石一樣<%= @ user.name%>使用紅寶石在導軌上登錄時在導航欄上顯示用戶名

繼承人的HTML

enter code here 

<header class="navbar navbar-fixed-top"> 
    <div class="navbar-inner"> 
    <div class="container"> 
     <%= link_to "sample app", root_path, id: "logo" %> 
     <nav> 
     <ul class="nav pull-right"> 
      <li><%= link_to "Home", root_path %></li> 
      <li><%= link_to "Help", help_path %></li> 
      <% if signed_in? %> 
      <li><%= link_to "Users", '#' %></li> 
      <li id="fat-menu" class="dropdown"> 
      <a href="#" class="dropdown-toggle" data-toggle="dropdown"> 
       Account 
       <b class="caret"></b> 
      </a> 
      <ul class="dropdown-menu"> 
       <li><%= link_to "Profile", user_path(current_user) %></li> 
       <li><%= link_to "Settings", '#' %></li> 
       <li class="divider"></li> 
       <li> 
       <%= link_to "Sign out", signout_path, method: 'delete' %> 
       </li> 
      </ul> 
      </li> 
     <% else %> 
      <li><%= link_to "Sign in", signin_path %></li> 
     <% end %> 
     </ul> 
     </nav> 
    </div> 
    </div> 
</header> 

回答

2

嘗試:

<%= current_user.name %> 
+0

awsome工作!謝謝! – 2012-07-24 20:36:51

相關問題