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.
#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