Created
March 19, 2016 19:49
-
-
Save adamkirkwood/9fe13e67f507234c7684 to your computer and use it in GitHub Desktop.
Sketchpacks.com OpenSearch implementation
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 PluginsController < ApplicationController | |
# ...snip... | |
def search | |
redirect_to plugins_path if search_query.blank? | |
@plugins = Plugin.search(search_query).page params[:page] | |
# redirect to plugin if the search returned a direct hit | |
redirect_to @plugins.first if @plugins && @plugins.try(:first).try(:slug) == search_query | |
end | |
# ...snip... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment