title: Implement jquery ui tabs with ajax in Rails?
body: <p>Does anyone know where I can find some example code for implementing ajax tabs with jquery ui in Ruby on Rails 3? I'm unable to find anything I can't seem to get it to work based on examples I have found for form and comment processing. Mind you, I am very new to ruby on rails. </p>
  
  <p>Based on the jquery ui tabs with ajax example from the jquery site, I have the following code:</p>
  
  <p>simple controller - <strong>maps_controller.rb</strong></p>
  
  <pre><code>  def index
    end
  
    def test1
      @test = "test string"
    end
  </code></pre>
  
  <p>associated view - <strong>index.html.erb</strong></p>
  
  <pre><code>&lt;script&gt;
          $(function() {
              $( "#tabs" ).tabs({
                  ajaxOptions: {
                      error: function( xhr, status, index, anchor ) {
                          $( anchor.hash ).html(
                              "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                              "If this wouldn't be a demo." );
                      }
                  }
              });
          });
          &lt;/script&gt;
  
  
  
  &lt;div class="demo"&gt;
  
  &lt;div id="tabs"&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#content_area"&gt;Preloaded&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;%= link_to "Test1" , test1_path %&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id="content_area"&gt;
          &lt;p&gt;Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.&lt;/p&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;&lt;!-- End demo --&gt;
  </code></pre>
  
  <p><strong>test1.html.erb</strong></p>
  
  <pre><code>&lt;%= @test %&gt;
  </code></pre>
  
  <p>The ajax functionality seems to work. When clicking the test1 tab, the entire page in loaded into the div with the appropriate data. Obviously this isn't the functionality desired - I just want the test1.html.erb to show, not it rendered with application.html.erb.</p>
  
  <p>I also have found various rails specific examples that use the convention of having a .js.erb file. (<a href="http://blog.bernatfarrero.com/jquery-and-rails-3-mini-tutorial/" rel="noreferrer">http://blog.bernatfarrero.com/jquery-and-rails-3-mini-tutorial/</a>)</p>
  
  <p>Any input on this would be great. </p>