Fix showing the query on the item search error page
Previously, the query wouldn't fill into the search box or page title if e.g. parsing had failed. Now it does! I'm not sure why the rescue strategy we previously had here doesn't work anymore (I'm sure it must've in the past sometime?), but this is simpler anyway, let's go!
This commit is contained in:
parent
bdefeb53d6
commit
1860f5b6be
1 changed files with 2 additions and 8 deletions
|
@ -130,6 +130,7 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
def search_error(e)
|
def search_error(e)
|
||||||
@items = []
|
@items = []
|
||||||
|
@query = params[:q]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { flash.now[:alert] = e.message; render }
|
format.html { flash.now[:alert] = e.message; render }
|
||||||
format.json { render :json => {error: e.message} }
|
format.json { render :json => {error: e.message} }
|
||||||
|
@ -139,14 +140,7 @@ class ItemsController < ApplicationController
|
||||||
def set_query
|
def set_query
|
||||||
q = params[:q]
|
q = params[:q]
|
||||||
if q.is_a?(String)
|
if q.is_a?(String)
|
||||||
begin
|
@query = Item::Search::Query.from_text(q, current_user)
|
||||||
@query = Item::Search::Query.from_text(q, current_user)
|
|
||||||
rescue
|
|
||||||
# Set the query string for error handling messages, but let the error
|
|
||||||
# bubble up.
|
|
||||||
@query = params[:q]
|
|
||||||
raise
|
|
||||||
end
|
|
||||||
elsif q.is_a?(ActionController::Parameters)
|
elsif q.is_a?(ActionController::Parameters)
|
||||||
@query = Item::Search::Query.from_params(q, current_user)
|
@query = Item::Search::Query.from_params(q, current_user)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue