Admin options in _menu not showing up

Forums > Book - Chapter 3 > Admin options in _menu not showing up

Login to post a new topic

Author Message
jperih
Member since 08 Jan 01:41
0 posts
Hi,
Found a few quirky things. Here’s one of them:

<ul> 
  <li><%= link_to 'Home', index_url %></li> 
  <li><hr size="1" width="90%" align="left"/></li> 
  <% if is_logged_in? %> 
    <li>Logged in as: <i><%= logged_in_user.username %></i></li> 
    <li><%= link_to 'My Profile', edit_user_path(logged_in_user) %></li> 
    <li><%= link_to 'Logout', {:controller => 'account', :action => 'logout'}, 
                               :method => :post %></li> 
  <% else %> 
    <li><%= link_to 'Signup', :controller => 'users', :action => 'new' %></li> 
    <li><%= link_to 'Login', :controller => 'account', :action => 'login' %></li> 
  <% end %>        
  <% if logged_in_user and logged_in_user.has_role?('administrator') %> 
    <li><hr size="1" width="90%" align="left"/></li> 
    <li><b>Admin Options</b></li> 
    <li><%= link_to 'Administer Users', users_path %></li> 
    <li><%= link_to 'Edit Pages', pages_path %></li> 
  <% end %> 
</ul> 

This is on page 78, an edit to _menu.rhtml partial, to show the Admin options, should an administrator be logged in.


This will ONLY work, if you change the line:

  <% if logged_in_user and logged_in_user.has_role?('administrator') %>


to this:

  <% if logged_in_user and logged_in_user.has_role?('Administrator') %> 


in other words, it appears to be case sensitive.


Could this be caused by version conflicts between the version of rails used in the book, and the one I currently have (which, I assume, is the one that comes with Leopard: Ruby 1.8.6 with Rails 1.2.6