Note that there are some explanatory texts on larger screens.

plurals
  1. POI can't get my search form and result views to render - using Thinking-sphinx along side existing search
    primarykey
    data
    text
    <p>I have a 2.3.11 Rails app, and I would like to add a fulltext search to be able to search on the 'articles' content and title. I am using Thinking-sphinx for this purpose. I just want to be able to click on the search link_to '/advanced_search' (on the home page) and have the search form come up, then once the search form is submitted have another view search_results.html.erb display a list of matching article(s). </p> <p>Problem: I found out that I really don't understand how views are actually rendered. I'm also not sure I got my routing correct. I've tried different things, but for some reason all the examples I found out there are different. </p> <p>So I have a search form /controllers/articles_controller/advanced_search :</p> <pre><code>&lt;% form_tag :controller =&gt; 'articles', :action =&gt; 'search', :method =&gt; 'get' do %&gt; &lt;%= text_field_tag :search, params[:search], :id =&gt; 'search_field' %&gt; &lt;%= submit_tag 'Search', :name =&gt; nil %&gt; &lt;% end %&gt; </code></pre> <p>And I have a second view to display the search results, /controllers/articles_controller/search_results.html.erb:</p> <pre><code>&lt;% @articles.each do |article| %&gt; &lt;li&gt;&lt;%= link_to article.name, :action =&gt; 'show', :id =&gt; article.id %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= article.archived? %&gt;&lt;/li&gt; &lt;% end %&gt; </code></pre> <p>This my model where I define the index for sphinx:</p> <p>class Article &lt; ActiveRecord::Base validates_presence_of :name #rest of validation and associations here</p> <p>define_index do indexes summary indexes :name end end </p> <p>This my controller and new search action /controllers/articles_controller:</p> <pre><code>class ArticlesController &lt; ApplicationController </code></pre> <p>load_and_authorize_resource </p> <p>def index @articles = Article.all</p> <pre><code>respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @articles } format.json { render :json =&gt; @articles } end </code></pre> <p>end</p> <p>def search @articles = Article.search params[:search]</p> <pre><code>respond_to do |format| format.html # format.xml { render :xml =&gt; @articles } format.json { render :json =&gt; @articles } end </code></pre> <p>end end</p> <p>In my routes.rb I have this line, which is probably not correct, but when I take it out, I get the routing error 'No route matches "/advance_search" with {method => get}</p> <pre><code>map.connect 'advance_search', :controller =&gt; "articles, :action =&gt; search </code></pre> <p>I would appreciate any ideas on how to have my views render correctly, assuming that everything else is correct.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload