Hi there, I''m going through this tutorial on Thinking Sphinx: http://railscasts.com/episodes/120-thinking-sphinx I''m really new to searches in rails; how do I get the search results to display on a separate search result page? I have a search form that appears on every page (in my application.html.erb template) that looks like this: <% form_for :recipes, :url => {:controller => "pages", :action => "searchresults"} do |f| %> <%= f.text_field :search %> <%= submit_tag "Search" %> <% end %> This is a recipe search, but it doesn''t even work because :search isn''t a field in the recipes table. I just want to grab a params[:search] that I can use in my controller. Here''s what my pages_controller.rb looks like: def searchresults @recipes = Recipe.search params[:search], :page => params[:page], :per_page => 10, :field_weights => {:title => 20}, :match_mode => :boolean end I have no problem with this code; I have a searchresults.html.erb that matches up just fine. But params[:search] == nil, so that''s no good. :( How should I construct my form? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 14, 9:34 pm, Dave Amos <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have no problem with this code; I have a searchresults.html.erb that > matches up just fine. But params[:search] == nil, so that''s no good. :( >Check params again. you search is there, just not where you think (hint: if you put <%= debug params %> in the view, that will dump all the params to the screen. alternatively just look in development.log. Fred> How should I construct my form? > > Thanks! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Sep 14, 9:34�pm, Dave Amos <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> >> I have no problem with this code; I have a searchresults.html.erb that >> matches up just fine. But params[:search] == nil, so that''s no good. :( >> > Check params again. you search is there, just not where you think > (hint: if you put <%= debug params %> in the view, that will dump all > the params to the screen. alternatively just look in development.log. > > FredThanks! I switched to a form_tag because I wasn''t querying the model. Here''s what I came up with: <% form_tag :action => ''searchresults'' do %> <%= text_field_tag :search %> <%= submit_tag "Search" %> <% end %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---