From 8519f9131be5f7bb4a8ed872e613fec1ae33e265 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 15 May 2010 14:01:15 -0400 Subject: [PATCH] item presentation is neat --- app/controllers/items_controller.rb | 2 +- app/models/item.rb | 2 ++ app/views/items/_item.html.haml | 3 +++ app/views/items/index.html.haml | 3 +-- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 app/views/items/_item.html.haml diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 2ed43f1b..3b9b5257 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -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 diff --git a/app/models/item.rb b/app/models/item.rb index 286bdc5d..fde15689 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -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 diff --git a/app/views/items/_item.html.haml b/app/views/items/_item.html.haml new file mode 100644 index 00000000..6fde22a8 --- /dev/null +++ b/app/views/items/_item.html.haml @@ -0,0 +1,3 @@ += div_for item do + = image_tag item.thumbnail_url, :alt => item.description, :title => item.description + = item.name diff --git a/app/views/items/index.html.haml b/app/views/items/index.html.haml index 23691c16..42252e9f 100644 --- a/app/views/items/index.html.haml +++ b/app/views/items/index.html.haml @@ -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