retain query on item page
This commit is contained in:
parent
55126756ea
commit
df3fcd101f
2 changed files with 9 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
class ItemsController < ApplicationController
|
class ItemsController < ApplicationController
|
||||||
|
before_filter :set_query
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params.has_key?(:q)
|
if params.has_key?(:q)
|
||||||
@query = params[:q]
|
|
||||||
begin
|
begin
|
||||||
@results = Item.search(@query).alphabetize.paginate :page => params[:page]
|
@results = Item.search(@query).alphabetize.paginate :page => params[:page]
|
||||||
rescue
|
rescue
|
||||||
|
@ -13,4 +14,10 @@ class ItemsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@item = Item.find params[:id]
|
@item = Item.find params[:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_query
|
||||||
|
@query = params[:q]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
= image_tag item.thumbnail_url, :alt => item.description, :title => item.description
|
||||||
= item.name
|
= item.name
|
||||||
|
|
Loading…
Reference in a new issue