Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom search
class HomeController < ApplicationController
class MovieSearch < FortyFacets::FacetSearch
model 'Movie' # which model to search for
custom :for_manual_handling
end
def index
@search = MovieSearch.new(params, Movie.all) # this initializes your search object from the request params
if @search.filter(:custom_filter).value.present?
@search = MovieSearch.new(params, Movie.near(...))
end
@movies = @search.result.paginate(page: params[:page], per_page: 5) # optionally paginate through your results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.