Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Merge 6448b8d into 837c274
Browse files Browse the repository at this point in the history
  • Loading branch information
HouseTrip CI User committed Feb 8, 2014
2 parents 837c274 + 6448b8d commit d05d826
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class SearchController < ApplicationController
before_filter :require_account!

def index
@search = Search.new(params[:search].fetch(:query, nil))
@search = Search.new(
scope: current_account.ideas,
query: params[:search].fetch(:query, nil))
end
end
7 changes: 4 additions & 3 deletions app/models/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ class Search
include ActiveModel::Conversion
extend ActiveModel::Naming

attr_accessor :query
attr_accessor :query, :scope

def initialize(query = nil)
def initialize(scope, query = nil)
@scope = scope || Idea
@query = query
end

def ideas
Idea.basic_search(query)
scope.basic_search(query)
end
end
10 changes: 6 additions & 4 deletions app/views/application/_search.html.haml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
= form_for(@search || Search.new, method: :get, html: { class: 'form-search' }) do |f|
.input-append
= f.text_field :query, class: 'input-medium search-query', placeholder: 'Search'
= f.submit 'Go', class: 'btn'
- if current_account
- search = @search || Search.new(scope: current_account.ideas)
= form_for(search, method: :get, html: { class: 'form-search' }) do |f|
.input-append
= f.text_field :query, class: 'input-medium search-query', placeholder: 'Search'
= f.submit 'Go', class: 'btn'

0 comments on commit d05d826

Please sign in to comment.