title: RJS: Ajaxified select_tag
body: <p>Since I didn't get the expected answer on my <a href="https://stackoverflow.com/questions/575862/rjs-using-observefield-on-selecttag">last question</a> I'll try to simplify and narrow my question:</p>
  
  <blockquote>
    <p>How can I build a dropdown-menu that uses AJAX (no submit-button) to call the show action of a certain controller?</p>
  </blockquote>
  
  <p>The following things are given:</p>
  
  <p><strong>Model-Association</strong> is <em>Categories HABTM Projects</em>, therefore the dropdown-menu consists of all category names.</p>
  
  <p>The <strong>view partial</strong> where the dropdown-menu should be implemented. Below the dropdown menu is a list of projects that should change according to the choice made in the dropdown menu:</p>
  
  <pre><code>   &lt;!-- placeholder for AJAX dropdown menu --&gt;
  
     &lt;!-- list of projects related to categories chosen by the select tag --&gt;
     &lt;ul class="projects"&gt;
       &lt;% @projects.each do |_project| %&gt;
         &lt;li&gt;
           &lt;%= link_to(_project.name, _project) %&gt;
         &lt;/li&gt;
       &lt;% end %&gt;
     &lt;/ul&gt;
  </code></pre>
  
  <p>The <strong>Categories controller</strong> with the show-action that should be called:</p>
  
  <pre><code>class CategoriesController &lt; ApplicationController
    def show
      # params[:id] should be the choice the user made in the dropdown menu
      @category = Category.find(params[:id])
      @projects = @category.projects.find(:all)
  
      respond_to do |format|
        format.html # show.html.erb
        format.js   # needed for ajax response?
      end
    end
  
    def index
      @projects = Category.find(params[:id]).projects.find(:all)
      @category = @project.categories.first
  
      respond_to do |format|
        format.html # index.html.erb
      end
    end 
  end
  </code></pre>
  
  <p>The <strong>route</strong> to call the show-action in the Categories controller:</p>
  
  <pre><code>category GET    /categories/:id    {:controller=&gt;"categories", :action=&gt;"show"}
  </code></pre>
  
  <p>How would you implement this? Any help is very apreciated!</p>