# Rails 3 - Loading a Subnav with Ajaxâ€¦ Whic h controller owns a subnav?

**URL:** <https://www.ruby-forum.com/t/rails-3-loading-a-subnav-with-ajaxa-whic-h-controller-owns-a-subnav/195592>\
**Category:** Rails\
**Created:** [September 26, 2010, 4:38am UTC](https://www.ruby-forum.com/t/rails-3-loading-a-subnav-with-ajaxa-whic-h-controller-owns-a-subnav/195592 "2010-09-26T04:38:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [September 26, 2010, 4:38am UTC](https://www.ruby-forum.com/t/rails-3-loading-a-subnav-with-ajaxa-whic-h-controller-owns-a-subnav/195592/1 "2010-09-26T04:38:16Z")

</div>

Once my Rails 3 app is loaded, a user can click an item which needs to  
then load a dynamic subnav.

My thinking is (since it needs to be dynamic) is onClick to make a  
jQuery AJAX call to the server and then to inject the HTML response  
into a DIV on the page…

What I’d like your advice on is how/where the subnav logic should live  
in the rails app, as I don’t have a navigation controller or view…  
But maybe I should have one?

Do I create a navigation controller? Or use the application  
controller? I also have a pages controller that I use for the landing  
page, about, contact, etc…

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [September 26, 2010, 10:00am UTC](https://www.ruby-forum.com/t/rails-3-loading-a-subnav-with-ajaxa-whic-h-controller-owns-a-subnav/195592/2 "2010-09-26T10:00:42Z")

</div>

On 26 September 2010 03:36, nobosh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Do I create a navigation controller? Or use the application  
> controller? I also have a pages controller that I use for the landing  
> page, about, contact, etc…

I don’t think there is a ‘correct’ answer to this, it depends entirely  
on your specific application. Generally if you put something in what  
seems intuitively to you to be the right place you will not go far  
wrong. Also make sure you write good automated tests so you can  
easily re-factor when you realise you did not get it right the first  
time, so you can move stuff about secure in the knowledge that you  
have probably not broken anything.

Colin

---

<div class="post-metadata">

**Author:** ![nobosh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecb155/32.png) [@nobosh](https://www.ruby-forum.com/u/nobosh)\
**Post date:** [September 27, 2010, 6:22am UTC](https://www.ruby-forum.com/t/rails-3-loading-a-subnav-with-ajaxa-whic-h-controller-owns-a-subnav/195592/3 "2010-09-27T06:22:51Z")

</div>

check the simple navigations plugin

> **[Simple Navigation Plugin Version 2](http://blog.andischacke.com/2009/10/simple-navigation-gemplugin-version-2.html)**
>
> About six months ago I wrote about the first release of the simple navigation plugin . It's a GemPlugin to generate the navigation for your ...
