I have this at the moment for creating my tabs, it works ok but was
wondering if it would be faster to have a basic partial with a series of
if statements ? Im just wondering if there are any overheads involved
with generating lis this way.
<pre>
#header navigation helper methods
def main_tabs(controller)
items = [ content_tag(''li'',
link_to(''Products'', categories_path),
:class => "page_item"),
content_tag(''li'',
link_to(''Pages'', pages_path), :class =>
"page_item"),
content_tag(''li'',
link_to(''Mail'', emails_path), :class =>
"page_item"),
content_tag(''li'',
link_to(''Accounts'', users_path), :class
=> "page_item")]
case controller
when /categories|products|parts|accessories|actions/
items[0] = content_tag(''li'',
link_to(''Products'',
categories_path), :class => "current_page_item")
when ''pages''
items[1] = content_tag(''li'',
link_to(''Pages'', pages_path),
:class => "current_page_item")
when ''emails''
items[2] = content_tag(''li'',
link_to(''Mail'', emails_path),
:class => "current_page_item")
when ''users'' && user.admin?
items[3] = content_tag(''li'',
link_to(''Accounts'',
users_path), :class => "current_page_item")
end
content_tag(''ul'', items.to_s,
:class=>''menu'')
end
</pre>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---