Permalink
Browse files

Let people be feature-able and made search better

  • Loading branch information...
Jarred-Sumner committed Feb 21, 2012
1 parent b9264d9 commit fb2ac4b942f06f2c9f45fcd755ec0dbc15ecb695
@@ -1,6 +1,5 @@
/*
*= require_self
- *= require jquery-ui-1.8.17.custom
*/
@import "bourbon";
@import "bootstrap";
@@ -1,7 +1,7 @@
class CompaniesController < ApplicationController
respond_to :json, :html
def index
- @companies = Company.where(:featured => true)
+ @featured = Company.where(:featured => true).limit(4) + Person.where(:featured => true).limit(4)
respond_to do |format|
format.html
format.json { render :json => Company.all.to_json }
@@ -48,7 +48,7 @@ def search
@first_name = params[:query]
@last_name = params[:query]
end
- @people = Person.where("first_name ilike ? OR last_name ilike ?", "%#{@first_name}%", "%#{@last_name}%" ).limit(4) unless params[:query] == ''
+ @people = Person.where("first_name ilike ? OR last_name ilike ?", "#{@first_name}%", "#{@last_name}%" ).limit(4) unless params[:query] == ''
@results = @companies + @people
@results.shuffle!
respond_to do |format|
@@ -4,12 +4,18 @@
<h3>Find out and stay up to date on most startup's funding</h3>
<input type='search' id='search' autocomplete='off' placeholder='Who is the company/person you want to know more about?' value='<%= params[:search] %>'/>
<ul id='companies_list'>
- <% @companies.each do |company| %>
+ <% @featured.each do |feature| %>
<li class='company unselectable'>
<h3>
- <a href='/companies/<%= company.id %>' class='unselectable'>
- <%= company.name %>
- </a>
+ <% if feature.class.name == 'Company' %>
+ <a href='/companies/<%= feature.id %>' class='unselectable'>
+ <%= feature.name %>
+ </a>
+ <% else %>
+ <a href='/people/<%= feature.id %>' class='unselectable'>
+ <%= feature.name %>
+ </a>
+ <% end %>
</h3>
</li>
<% end %>
@@ -0,0 +1,6 @@
+class AddFeaturedToPerson < ActiveRecord::Migration
+ def change
+ add_column :people, :featured, :boolean
+
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120218061729) do
+ActiveRecord::Schema.define(:version => 20120221040721) do
create_table "companies", :force => true do |t|
t.string "name"
@@ -42,6 +42,7 @@
t.string "zip_code"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.boolean "featured"
end
create_table "related_people", :force => true do |t|

0 comments on commit fb2ac4b

Please sign in to comment.