Class: ImageSearchController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/image_search_controller.rb

Instance Method Summary collapse

Instance Method Details

#search_repositoryObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/controllers/image_search_controller.rb', line 2

def search_repository
  catch_network_errors do
    tags_enabled = params[:tags] || 'false'
    result = image_search_service.search(term: params[:search], tags: tags_enabled)

    respond_to do |format|
      format.js { render json: prepare_for_autocomplete(result) }
      format.html do
        render partial: 'repository_search_results', locals: { repositories: result }
      end
    end
  end
end