forked from OpenNeo/impress
item presentation is neat
This commit is contained in:
parent
cee6ee68a1
commit
8519f9131b
4 changed files with 7 additions and 3 deletions
|
@ -3,7 +3,7 @@ class ItemsController < ApplicationController
|
|||
if params.has_key?(:q)
|
||||
@query = params[:q]
|
||||
begin
|
||||
@results = Item.search(@query).all
|
||||
@results = Item.search(@query).alphabetize.all
|
||||
rescue
|
||||
flash[:alert] = $!.message
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ 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
|
||||
|
||||
scope :alphabetize, order('name ASC')
|
||||
|
||||
# Not defining validations, since this app is currently read-only
|
||||
|
||||
def species_support_ids
|
||||
|
|
3
app/views/items/_item.html.haml
Normal file
3
app/views/items/_item.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
= div_for item do
|
||||
= image_tag item.thumbnail_url, :alt => item.description, :title => item.description
|
||||
= item.name
|
|
@ -1,5 +1,4 @@
|
|||
= form_tag items_path, :method => :get do
|
||||
= text_field_tag :q, @query
|
||||
= submit_tag 'Search', :name => nil
|
||||
- if @results
|
||||
= @results.inspect
|
||||
= render @results
|
||||
|
|
Loading…
Reference in a new issue