Created
January 31, 2017 13:41
-
-
Save axelerator/e512dd751b29ff6559efc277dc5c00df to your computer and use it in GitHub Desktop.
Custom search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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