Created
February 27, 2009 20:09
-
-
Save mghaught/71668 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in ApplicationController | |
def admin_nav | |
return unless current_user | |
@sec_nav = [] | |
@current_main = "Admin" | |
@sec_nav << {:name => "Users", :link => users_path} if admin? | |
@sec_nav << {:name => "Invites", :link => invites_path} if admin? | |
end | |
# in ApplicationHelper | |
def main_nav | |
top_nav = [] | |
return top_nav unless current_user | |
top_nav << {:name => "Dashboard", :link => dashboard_path} | |
top_nav << {:name => "Character", :link => characters_path} | |
top_nav << {:name => "Quest", :link => locations_path} | |
top_nav << {:name => "Admin", :link => users_path} if admin? | |
top_nav | |
end | |
def secondary_nav | |
return [] unless current_user | |
@sec_nav || [] | |
end | |
def current_main | |
@current_main || controller.controller_name.titleize | |
end | |
def current_second | |
@current_second || controller.controller_name.titleize | |
end | |
# specific controller | |
before_filter :admin_nav | |
# In layout: | |
<div id="main-navigation"> | |
<%= render :partial => "shared/navigation", :locals => {:tabs => main_nav, :current => current_main} %> | |
<div class="clear"></div> | |
</div> | |
# navigation partial | |
<ul> | |
<% for tab in tabs | |
cs = [] | |
cs << "first" if tab == tabs.first | |
cs << "active" if tab[:name] == current | |
%> | |
<li class="<%= cs.join(' ') %>"><%= link_to tab[:name], tab[:link] %></li> | |
<% end %> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment