title: Thinking_Sphinx working in console but not in Rails application
body: <p>Environment Rails 3.0.4, Ruby 1.8.7, Sphinx 0.99, Dreamhost VPS</p>
  
  <p>I have a simple blog search set up as follows:</p>
  
  <p>Controller:</p>
  
  <pre><code>def blog_search_results     
      @blog_search_results = BlogPost.search( params[:search_param] )
      respond_to do |format| 
        format.html { render :partial =&gt; 'blog_search_results', :layout=&gt;false }
        format.xml  { render :xml     =&gt; @blog_search_results }
      end     
  end
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;% if !@blog_search_results.empty? %&gt;
      &lt;div id="main_content"&gt;
          &lt;table id="pending_blog_list"&gt;&lt;tr id="header"&gt;&lt;td&gt;Blog Title&lt;/td&gt;&lt;td&gt;Created by&lt;/td&gt;&lt;td&gt;Created on&lt;/td&gt;&lt;/tr&gt;
          &lt;% @blog_search_results.each do |blog_post| %&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;%= link_to blog_post.title, blog_named_link(blog_post, :show) %&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%= blog_post.posted_by.display_name -%&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;%= blog_post.created_at.strftime("%x") -%&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;% end %&gt;
          &lt;/table&gt;
          &lt;%= will_paginate(@blog_search_results, {:form_name =&gt; :blog_show_params, :param_name =&gt; :page} ) %&gt;
      &lt;/div&gt;
  &lt;% else %&gt;
      &lt;h2&gt;No blog posts that match your search were found&lt;/h2&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Everything works perfectly in my development environment. In the production environment, when I launch a console ("rails c production") and type:</p>
  
  <blockquote>
    <p>irb(main):003:0>
    BlogPost.search("video")</p>
  </blockquote>
  
  <p>I get the expected 4 results of posts with the word 'video'. However in the actual app, the controller keeps returning a '404 Not Found'</p>
  
  <pre><code>Started GET "/blog_posts/blog_search_results?search_param=video" 
  Processing by BlogPostsController#blog_search_resul as HTML   
  Parameters: {"search_param"=&gt;"video"} 
  Completed in 27ms 
  Rendered layouts/application.html.erb (22.3ms)
  Rendered public/404.html within layouts/blog_posts (24.7ms)
  </code></pre>
  
  <p>My sphinx.yml setup is as follows:</p>
  
  <pre><code>staging:
    pid_file: '/www.assetcorr.com/current/log/searchd.pid'
    searchd_file_path: 'www.assetcorr.com/shared/db/sphinx'
    bin_path: '/home/avitus/local/bin'
  </code></pre>
  
  <p>I see the index in the in the shared/db/sphinx folder. It appears after I run ts:index.
  The searchd.pid file is in the log folder and the PID matches the searchd daemon.
  The bin_path is correct and I've added it to the path in the .bash_profile file.</p>
  
  <p>Does anyone have any ideas what could be causing this?</p>
  
  <p>-- UPDATE --</p>
  
  <p>It look as though the reason this isn't working is that the controller method is being accessed via an AJAX call:</p>
  
  <pre><code>$(document).ready(function() {
    $("#search_param").observe_field(0.5, function( ) { 
      $.get("/blog_posts/blog_search_results", { search_param: this.value },
        function(data){   
      $("#search_results").html(data);
        }, "html");
      });
    });
  });
  </code></pre>
  
  <p>When I remove the AJAX call and resort to a plain vanilla GET request then it works perfectly. I have no idea why that would be.</p>