Skip to content

Instantly share code, notes, and snippets.

@cbeer
Last active August 29, 2015 14:01
Show Gist options
  • Save cbeer/fb97d657ff7a7bd12ee2 to your computer and use it in GitHub Desktop.
Save cbeer/fb97d657ff7a7bd12ee2 to your computer and use it in GitHub Desktop.
module BlacklightConfigurationHelper
include Blacklight::ConfigurationHelperBehavior
def default_sort_field
if params.has_key? :q
active_sort_fields.select { |k,config| config.default_for_user_query }.first || super
else
super
end
end
end
class CatalogController
...
configure_blacklight do |config|
config.add_sort_field 'relevance', default_for_user_query: true
config.add_sort_field 'title', default: true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment