app/controllers/search_controller.rb
# there are various object types which can be the only result. This method handles redirecting to all of them
there are various object types which can be the only result. This method handles redirecting to all of them
there are various object types which can be the only result . This method handles redirecting to all of them
def redirect_to_page(result, options={})
    modified_params = options[:params].dup
    modified_params.delete(:type) if modified_params[:type] == ['all']
    modified_params.delete(:sort_by) if modified_params[:sort_by] == 'score'
    modified_params.delete_if{ |k, v| ![ 'sort_by', 'type' ].include?(k) }
    modified_params[:q] = @querystring
    if options[:total_results] > 1
      flash[:notice] = I18n.t(:flash_notice_redirected_from_search_html_more_results, search_string: @querystring, more_results_url: search_path(modified_params.merge({ show_all: true })))
    elsif options[:total_results] == 1
      flash[:notice] = I18n.t(:flash_notice_redirected_from_search_html, search_string: @querystring, more_results_url: search_path(modified_params.merge({ show_all: true })))
    end
    result_instance = result['instance']
    if result_instance.class == Collection
      redirect_to collection_path(result_instance.id)
    elsif result_instance.class == Community
      redirect_to community_path(result_instance.id)
    elsif result_instance.class == DataObject
      redirect_to data_object_path(result_instance.id)
    elsif result_instance.class == User
      redirect_to user_path(result_instance.id)
    elsif result_instance.class == TaxonConcept
      redirect_to taxon_overview_path(result_instance.id)
    elsif result_instance.class == ContentPage
      redirect_to cms_page_path(result_instance.id)
    end
  end
def redirect_to_page ( result , options = { } ) modified_params = options [ :params ] . dup modified_params . delete ( :type ) if modified_params [ :type ] == [ 'all' ] modified_params . delete ( :sort_by ) if modified_params [ :sort_by ] == 'score' modified_params . delete_if { | k , v | ! [ 'sort_by' , 'type' ] . include? ( k ) } modified_params [ :q ] = @querystring if options [ :total_results ] > 1 flash [ :notice ] = I18n . t ( :flash_notice_redirected_from_search_html_more_results , search_string : @querystring , more_results_url : search_path ( modified_params . merge ( { show_all : true } ) ) ) elsif options [ :total_results ] == 1 flash [ :notice ] = I18n . t ( :flash_notice_redirected_from_search_html , search_string : @querystring , more_results_url : search_path ( modified_params . merge ( { show_all : true } ) ) ) end result_instance = result [ 'instance' ] if result_instance . class == Collection redirect_to collection_path ( result_instance . id ) elsif result_instance . class == Community redirect_to community_path ( result_instance . id ) elsif result_instance . class == DataObject redirect_to data_object_path ( result_instance . id ) elsif result_instance . class == User redirect_to user_path ( result_instance . id ) elsif result_instance . class == TaxonConcept redirect_to taxon_overview_path ( result_instance . id ) elsif result_instance . class == ContentPage redirect_to cms_page_path ( result_instance . id ) end end
there are various object types which can be the only result.
there are various object types which can be the only result .
result
<not_specific>
options
<not_specific>