From df3fcd101fceabd54a436b9595b839770034385a Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 7 Jun 2010 20:02:46 -0400 Subject: [PATCH] retain query on item page --- app/controllers/items_controller.rb | 9 ++++++++- app/views/items/_item.html.haml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index c590c7a3..e391c5a8 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -1,7 +1,8 @@ class ItemsController < ApplicationController + before_filter :set_query + def index if params.has_key?(:q) - @query = params[:q] begin @results = Item.search(@query).alphabetize.paginate :page => params[:page] rescue @@ -13,4 +14,10 @@ class ItemsController < ApplicationController def show @item = Item.find params[:id] end + + private + + def set_query + @query = params[:q] + end end diff --git a/app/views/items/_item.html.haml b/app/views/items/_item.html.haml index 406ebbef..fa456569 100644 --- a/app/views/items/_item.html.haml +++ b/app/views/items/_item.html.haml @@ -1,3 +1,3 @@ -= link_to item, :class => 'item' do += link_to item_path(item, :q => @query), :class => 'item' do = image_tag item.thumbnail_url, :alt => item.description, :title => item.description = item.name