diff options
author | francis <francis> | 2008-03-31 17:38:10 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-31 17:38:10 +0000 |
commit | fcf14f27fb61ce37457b75fd17dc3ea664035c2e (patch) | |
tree | dcf6a501e124ebcd0f88059e3ca75a4e0091b304 | |
parent | 15dc1f17ba6d2e08e38aff1a4293574247d62759 (diff) |
Preserve search order when you edit a query
-rw-r--r-- | app/controllers/general_controller.rb | 8 | ||||
-rw-r--r-- | app/views/general/search.rhtml | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 6463ca556..9b6f9dfd2 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -5,7 +5,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: general_controller.rb,v 1.11 2008-03-31 17:20:58 francis Exp $ +# $Id: general_controller.rb,v 1.12 2008-03-31 17:38:10 francis Exp $ class GeneralController < ApplicationController @@ -40,10 +40,12 @@ class GeneralController < ApplicationController # Just does a redirect from ?query= search to /query def search_redirect @query = params[:query] - if @query.nil? + @sortby = params[:sortby] + if @query.empty? + @query = nil render :action => "search" else - redirect_to search_url(:query => @query) + redirect_to search_url(:query => @query, :sortby => @sortby) end end diff --git a/app/views/general/search.rhtml b/app/views/general/search.rhtml index 9f021e540..84270c889 100644 --- a/app/views/general/search.rhtml +++ b/app/views/general/search.rhtml @@ -11,6 +11,7 @@ <% form_tag({:action => "search_redirect"}, {:id => "search_form"}) do %> <p> <%= text_field_tag 'query', @query, { :size => 40 } %> + <%= hidden_field_tag 'sortby', params[:sortby] %> <%= submit_tag "Search" %> <% if not @search_results.nil? and not @search_results.empty? %> <a href="/search">Advanced tips</a> |