Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:03:08+00:00 2026-05-25T00:03:08+00:00

I am building a way to easily include navigation (tabs and subnavs) in my

  • 0

I am building a way to easily include navigation (tabs and subnavs) in my views. I should be able to have different navigations for different controllers, and for different actions within those controllers.

Currently I am using this simple helper method:

def nav_for(tabs_hash, *active_tabs)
  content_tag(:div, 
    tabs_hash[:tab_info].map { |tab| tab == 'spacer' ?
                            content_tag(:div, '', :class => 'nav-spacer') :
                            link_to(tab[:name], tab[:path], :class => [tab[:class], ("active" if active_tabs.include? tab[:id])].join) 
                  }.join("\n").html_safe,
  :class => tabs_hash[:div_class])
end

Which takes a hash that includes the info for the navigation items and parses it out. I am putting these hashes in methods in the controllers, but this prevents me from accessing the navigation hashes from other controllers.

My question is, where would be the best place to store the navigation information? It’s also important that it has access to parameters, because some links are dynamically generated based on query strings.

I’m just looking for the best practices for this scenario. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:03:09+00:00Added an answer on May 25, 2026 at 12:03 am

    I would say that use of formatting and markup in a helper is a bad idea, why not split this off into a layout partial which would abstract the data from your view. As far as storing the data I would consider how flexible this needs to be at runtime. Can you get away with using a YAML file to define links?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a Firefox extension and have come a long way. One of
I'm building my project with maven so according to maven way, config should be
I am currently considering the best way of building a relatively complex page in
I've encountered a problem where part way through building a solution, VS 2010 becomes
Is there an easy way of dynamically building a filepath in .Net? At the
I am building a small rails app and I need a way to generate
I was wondering if anyone knows a way to prevent building unneeded device drivers
I've been building a HTML (email/page) composition tool in Ember.js as a way of
I am building a .NET MVC web application. Is cloud hosting the way to
is there a way with javascript/jquery to prevent images from loading? I am building

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.