Eric DUMINIL
2007-Dec-13 10:34 UTC
Accessing directly to show action with a submit button.
Hi everybody! I''m working on a google-like search engine, using Ferret to index documents on a smb share. Everything works fine, but I still would like to get rid of the useless action ''check_query'', that doesn''t do anything else than redirecting to ''show'' with an id parameter (queries don''t need to be checked/sanitized for Ferret AFAIK). # documents_controller.rb ################################## ... def check_query redirect_to :action=>''show'', :id=>params[:query] end def show @query=params[:id] .... ######################################################## # documents/index.haml ################################### .... -form_tag(:action=>:check_query) do = text_field_tag :query, @query, :size=>60, :class=>''text_field'' = submit_tag "Search!", :class => ''btn'' ... ######################################################## # routes.rb ############################################### ActionController::Routing::Routes.draw do |map| map.resources :documents, :collection=>{:check_query=>:post}, :member=>{:download=>:get} map.connect ''documents/:id'', :controller=>''documents'', :action=>''show'', :id => /.*/ .... ######################################################### I use this check_query action only because I didn''t succeed in configuring form_tag to send "get" method with id parameter = query. I tried -form_tag({:action=>:show},{:method=>:get}) do = text_field_tag :id, @query, :size=>60, :class=>''text_field'' without success... The submit button redirects to :index with those parameters: {"commit"=>"Search!", "action"=>"index", "id"=>"some query", "controller"=>"documents"} Do you know by any chance how I could do this? Thanks, Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---