title: Sortable menu for complex rails application
body: <p>I have a Rails app that contains several controllers (for different pages of my website). One controller for regular text pages, separate one for gallery etc. Now, what I need is a sortable menu for all of my pages.</p>
  
  <p>I've created model called <code>MenuItems</code>, which has a position number and polymorphic association to all of the models which need to be sorted:</p>
  
  <pre><code>class MenuItem &lt; ActiveRecord::Base
    belongs_to :sortable, :polymorphic =&gt; true
  end
  </code></pre>
  
  <p>Problem is that some of the MenuItems should point to the related model instance itself (like <code>show</code> action of a regular text page), and here my associations will do the trick. But I also need to list <code>index</code> actions (like the gallery listing page) on my menu, and to implement that I will need to either write some complex and unclear logic in the model and controller, or to add another field for <code>url</code>, providing some kind of interface for administrator to populate these urls.</p>
  
  <p>It already looks clumsy and from my experience, if you do something in rails the complex way, you are doing it wrong. But what is the best approach? How do you usually deal with complex menus in your application?</p>