Simple search form passing the searched string through GET
Posted
by Brian Roisentul
on Stack Overflow
See other posts from Stack Overflow
or by Brian Roisentul
Published on 2010-06-15T14:11:45Z
Indexed on
2010/06/15
14:12 UTC
Read the original article
Hit count: 219
ruby-on-rails
Hi,
I'd like my Search form to return the following url after submit:
/anuncios/buscar/the_text_I_searched
My form is the following:
<% form_for :announcement, :url => search_path(:txtSearch) do |f| %>
<div class="searchBox" id="basic">
<%= text_field_tag :txtSearch, params[:str_search].blank? ? "Buscá tu curso rápido y fácil." : params[:str_search], :maxlength=> 100, :class => "basicSearch_inputField", :onfocus => "if (this.value=='Buscá tu curso rápido y fácil.') this.value=''", :onblur => "if(this.value=='') { this.value='Buscá tu curso rápido y fácil.'; return false; }" %>
<div class="basicSearch_button">
<input type="submit" value="BUSCAR" class="basicSearch_buttonButton" />
<br /><a href="#" onclick="javascript:jQuery('#advance').modal({opacity:60});">Busqueda avanzada</a>
</div>
</div>
<% end %>
My routes' line for search_path is this:
map.search '/anuncios/buscar/:str_search', :controller => 'announcements', :action => 'search'
Well, this will work if I manually type the url I want in the brower, but definitely, if you look at the form's url, you'll find a ":txtSearch" parameter, which is not giving me the actual value of the text field when the form is submitted. And that's what I'd like to get!
Could anybody help me on this?
© Stack Overflow or respective owner