title: Rails, hooking into controllers
body: <p>OK, here's my problem:</p>
  
  <p>I have a <code>HomeController</code> with an action, say <code>index</code>, that would render a landing page for my site. The site also has a bunch of other Controllers that implement actions for various other functionalities.</p>
  
  <p>I want a dynamic navigation bar on my home page and what I'm looking for is that <code>HomeController#index</code> goes to every other Controller in my app and calls a particular method that would return and object with link details, for example, <code>HomeController#index</code> would go to <code>ContactController</code> and call a method <code>get_link</code> which would return something like:</p>
  
  <pre><code>{label: "Contact", url: "/contact"}
  </code></pre>
  
  <p>Similarly <code>HomeController#index</code> would try calling <code>get_link</code> on every other controller until it has collected an <code>Array</code> of link objects which could then be passed to the View to render navigation.</p>
  
  <p>I tried doing this through metaprogramming in Modules and using <strong><code>included</code></strong> hook method (getting my references from a <a href="http://www.sitepoint.com/rubys-important-hook-methods/" rel="nofollow">Sitepoint tutorial</a>). But that didn't work. Then I read somewhere that I may have to use <strong><code>ActiveSupport::Concern</code></strong> for ths kind of functionality, but I'm not sure how to go about it. I've worked on PHP CMS like Drupal and WordPress any they implement this using hooks, which is more-or-less what I'm looking for here. Any ideas?</p>