I've tried suggested different options in different tickets but nothing worked out me and getting this error
AbstractController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".)
Can you please let me know what is wrong in this code
def show
es = @external_search
if es.search_type == 'internal' && ['json','xml'].include?(params[:format])
rs = @external_search.resume_search
smws = rs.connection.daxtra_smws
dax_xml_resp = RestClient.post(smws.hostaddress__c + 'ws/dispatch',es.request_input,{:content_type => 'text/xml', :accept => 'application/xml', :timeout=> 90})
cIds = []
cHash = Hash.new
results = []
search_results = process_results(dax_xml_resp)
cIds = cIds.concat(search_results[:candidate_ids]).uniq
cHash = cHash.merge(search_results[:hash])
results = results.concat(search_results[:results]).uniq unless search_results[:results].nil?
if(!es.match_vacancy_id.blank?)
match_results = search_results
end
#if !es.match_vacancy_id.nil?
#match_results = process_results(es.daxtra_match_vacancy[:response].body) rescue nil
#unless match_results.nil?
#cIds = cIds.concat(match_results[:candidate_ids]).uniq
#cHash = cHash.merge(match_results[:hash])
#results = results.concat(match_results[:results]).uniq unless match_results[:results].nil?
#end
#end
resume_results = []
fields_needed = []
if !es.fields_to_select.blank?
fields_needed = ['Id','TR1__External_Candidate_Id__c']
fields_needed.push(es.fields_to_select.to_s.split(','))
end
unless results.nil?
tr_contacts = []
cIds.in_groups_of(1000){|group|
processed_group = group.compact.reject(&:blank?)
#tr_contacts += rs.connection.soap(rs.session_id).find_where('Contact', TR1__External_Candidate_Id__c: processed_group, ["Id", "FirstName", "CreatedBy"]).records
if !fields_needed.blank?
tr_contacts += rs.connection.soap(rs.session_id).find_where('Contact', {'TR1__External_Candidate_Id__c' => processed_group} , fields_needed.uniq)
else
tr_contacts += rs.connection.soap(rs.session_id).find_where('Contact', {'TR1__External_Candidate_Id__c' => processed_group})
end
}
tr_contacts.each {|x|
cHash[x.TR1__External_Candidate_Id__c]["Result"]["Score"] = "#{cHash[x.TR1__External_Candidate_Id__c]["Result"]["Score"].to_i.round}%"
cHash[x.TR1__External_Candidate_Id__c]["Result"]["badges"] = [{:name => 'match', :text_color => 'blue', :color => 'grey'}] if !match_results.nil? && match_results[:candidate_ids].include?(x.TR1__External_Candidate_Id__c)
resume_result = Hash["tr-object" => x.to_hash, "match-attributes" => cHash[x.TR1__External_Candidate_Id__c]["Result"].merge({"daxtra" => cHash[x.TR1__External_Candidate_Id__c]["Result"]})]
resume_results << resume_result
}
end
if resume_results.blank?
es.status_line1 = "<strong>#{es.name}</strong>"
es.retry = 0
es.result_count = 0
else
es.status_line1 = "<strong title='#{resume_results.size} Result(s)'>#{es.name}</strong>"
es.result_count = resume_results.size
es.retry = 0
end
es.status_line2 = "<div title='[Ref:#{es.id}] #{es.message}'>Status: <strong>Ready</strong></div>"
#h = Hash["a" => 100, "contact-array" => ca]
response_hash = {:ResumeSearch=>{:Status=>{:Code=>"100", :Description=>"OK"}, :data=>{:result=> resume_results}}}
#rs.connection.soap(rs.session_id).update('TR1__ResumeSearch__c', Id: rs.id, TR1__result_url__c: request.fullpath) #TakingTooMuchTime
respond_to do |format|
format.html { render :text => parsed_xml }
#format.html { render :text => h.to_json }
format.xml {
store_return_to
render :xml => parsed_xml }
format.json {
store_return_to
render json: response_hash.to_json }
end
end
if es.search_type == 'external' && ['json','xml'].include?(params[:format])
url = "https://#{es.host}/jwb/dispatch?db=#{es.database}&handle=#{es.request_id}&action=search_results"
ext_search = RestClient.get(url, :timeout => REST_TIMEOUT)
response = JSON.parse(ext_search)
plain = Base64.decode64(response['results'])
dresjson = Hash.from_xml(plain)
json_out = dresjson.to_json
if JSON.parse(json_out)['ZZ']['cv_entry'].class == Hash
new_json = car = {:ZZ => {:cv_entry => [JSON.parse(json_out)['ZZ']['cv_entry']]} }
json_out = new_json.to_json
end
result_count = JSON.parse(json_out)['ZZ']['cv_entry'].size unless json_out.blank? #rescue nil
es.status_line2 = "<div title='#{es.message}'>Status: <strong>Ready</strong></div>"
if !result_count.nil?
es.status_line1 = "<strong title='#{es.name} - #{result_count} Result(s)'>#{es.name}</strong>"
es.result_count = result_count
end
es.status_line2 = "<div title='[Ref:#{es.id}] #{es.message}'>Status: <strong>Ready</strong></div>"
respond_to do |format|
#format.html { render :text => response }
#format.html { render :text => tr_contacts }
format.xml { render :xml => plain }
format.json { render json: json_out }
end
end
es.save
es.to_intercom
end
Thanks
Aucun commentaire:
Enregistrer un commentaire