1
0
Fork 0
forked from OpenNeo/impress

pagination for results

This commit is contained in:
Emi Matchu 2010-05-15 14:14:17 -04:00
parent a8318323ef
commit 3062dd9376
3 changed files with 6 additions and 1 deletions

View file

@ -3,7 +3,7 @@ class ItemsController < ApplicationController
if params.has_key?(:q)
@query = params[:q]
begin
@results = Item.search(@query).alphabetize.all
@results = Item.search(@query).alphabetize.paginate :page => params[:page]
rescue
flash[:alert] = $!.message
end

View file

@ -2,6 +2,9 @@ class Item < ActiveRecord::Base
set_table_name 'objects' # Neo & PHP Impress call them objects, but the class name is a conflict (duh!)
set_inheritance_column 'inheritance_type' # PHP Impress used "type" to describe category
cattr_reader :per_page
@@per_page = 30
scope :alphabetize, order('name ASC')
# Not defining validations, since this app is currently read-only

View file

@ -1,4 +1,6 @@
= form_tag items_path, :method => :get do
= text_field_tag :q, @query
= submit_tag 'Search', :name => nil
= will_paginate @results
= render @results
= will_paginate @results