UPDATED 6/29/12
I was able to configure the search and sidebar to filter my search results using Sunspot and act-as-taggable with Rails. I read this tutorial here but I still cannot select the mutliple filter right away. When I select a filter, the names of other subcategories still disappear. What am I missing?
My original question is:
I'm not quite sure how to select multiple faces at once, filtering the data. Thus, I have several subcategories, i.e. (Hiking, skiing, etc.) I want to be able to choose hiking and climbing at the same time, therefore the data given are only those objects of hiking and climbing. Right now I choose one (say, a trip) and all other options disappear. Can someone explain?
Below is my code:
Gear controller
def index @search = Gear.solr_search do exclusions = [] fulltext params[:search] exclusions << with(:sub_category_name, params[:name]) if params[:name].present? exclusions.compact! exclusions = nil if exclusions.empty? facet :sub_category_name facet :sub_category_name, :exclude => exclusions, :name => :all_categories paginate(page: params[:page], :per_page => 15) end @gears = @search.results end
** View Turn Signal **
<div class="gears_container"> <div class="side_bar_search"> <%= form_tag gears_path, :method => :get do %> <p> <%= text_field_tag :keywords, params[:keywords] , class: 'gearsearchbar' %> <%= submit_tag "Search", :name => nil, class: 'btn btn-inverse gearsearchbutton' %> </p> <% end %> <div class="sidebar_section">Sub Category</div> <ul> <% for row in @search.facet(:all_categories).rows %> <li class="sidebar_options"> <% if params[:name].present? %> <strong><%= row.value %></strong>(<%= link_to "remove", :name => nil %>) <% else %> <%= link_to row.value, :name => row.value %> (<%= row.count %>) <% end %> </li> <% end %> </ul> </div> <div c <div class="search_results_gear"> <% @hits.each do |gear| %> <%= render partial: 'gear', locals: {gear: gear} %> <% end %> <div style="clear:both"></div> <%= will_paginate @hits, class: 'flickr_pagination' %> </br> </div> </div>
Gear model
class Gear < ActiveRecord::Base attr_accessible :title, :size, :price, :sub_category_id, :user_id, :image, :image_a, :remote_image_url, :color, :year, :latefee, :cancellation, :minrental, :policy, :about, :address, :city, :state, :zip, :sub_category_name belongs_to :user belongs_to :sub_category has_one :category, :through => :sub_category has_many :comments, :dependent => :destroy has_many :line_items require 'carrierwave/orm/activerecord' mount_uploader :image, GearpicUploader mount_uploader :image_a, GearpicUploader before_destroy :ensure_not_referenced_by_any_line_item acts_as_taggable_on :tags validates :title, presence: true validates :size, presence: true validates :price, presence: true validates :sub_category_id, presence: true validates :user_id, presence: true searchable do text :title, :size, :price, :year, :zip, :state, :city, :minrental, :about, :latefee, :color text :user_firstname do user.firstname end text :user_lastname do user.lastname end