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