ActionView::Template::Error (undefined method `strip!’ for nil:NilClass)
当我插入超过 100,000 条记录时,我似乎遇到了这个错误。我知道它可以支持的远不止这些。错误如下和相关类的代码。
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
2015-07-01 08:14:24.512:INFO:/:Started GET”/search?type=digital_object” for 129.118.15.44 at 2015-07-01 08:14:24 -0500|
2015-07-01 08:14:24.512:INFO:/:Processing by SearchController#search as HTML| 2015-07-01 08:14:24.512:INFO:/: Parameters: {“type”=>”digital_object”}| Jul 01, 2015 8:14:24 AM org.apache.solr.core.SolrCore execute INFO: [collection1] webapp= path=/select params={facet=true&sort=title_sort+asc&facet.limit=100&qf=four_part_id^3+title^2+finding_aid_filing_title^2+fullrecord&wt=json&rows=10&defType=edismax&pf=four_part_id^4&start=0&q=*:*&facet.field=repository&facet.field=primary_type&facet.field=subjects&facet.field=source&facet.field=linked_agent_roles&fq=types:(“digital_object”)&fq=-exclude_by_default:true&fq=publish:true} hits=203799 status=0 QTime=15 2015-07-01 08:14:24.590:INFO:/: Rendered G:/archivesspace/plugins/vva/public/views/search/_components_switch.html.erb (15.0ms)| 2015-07-01 08:14:24.590:INFO:/: Rendered search/_filter.html.erb (0.0ms)| 2015-07-01 08:14:24.606:INFO:/: Rendered search/_pagination_summary.html.erb (16.0ms)| 2015-07-01 08:14:24.637:INFO:/: Rendered search/_inline_results.html.erb (47.0ms)| 2015-07-01 08:14:24.637:INFO:/: Rendered search/results.html.erb within layouts/application (62.0ms)| 2015-07-01 08:14:24.653:INFO:/:Completed 500 Internal Server Error in 141.0ms| 2015-07-01 08:14:24.653:INFO:/:|ActionView::Template::Error (undefined method `strip!’ for nil:NilClass):| 17: <% elsif result[“primary_type”] ===“repository” %>| 18: <%= link_to result[‘title’], :controller => :search, :action => :repository, :repo_id => id %>| 19: <% else %>| 20: <%= link_to title_or_finding_aid_filing_title( result ) , :controller => :records, :action => result[“primary_type”], :id => id, :repo_id => repo_id %>| 21: <% end %>| 22: | 23: | app/helpers/application_helper.rb:22:in `title_or_finding_aid_filing_title’| app/views/search/_inline_results.html.erb:20:in `_app_views_search__inline_results_html_erb___996910774_15116’| app/views/search/_inline_results.html.erb:5:in `_app_views_search__inline_results_html_erb___996910774_15116’| app/helpers/application_helper.rb:134:in `render_aspace_partial’| app/views/search/results.html.erb:13:in `_app_views_search_results_html_erb__332589766_15048’| app/controllers/search_controller.rb:21:in `search’| app/controllers/search_controller.rb:20:in `search’||| |
_inline_results.html.erb
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<% if search_data.results? %>
<%= render_aspace_partial :partial =>“search/pagination_summary”, :locals => {:search_data => search_data} %> <ul class=“results-list”> <% search_data[‘results’].each do |result| %> <% id = JSONModel(result[“primary_type”]).id_for(result[‘uri’]) repo_id = JSONModel(:repository).id_for(JSONModel.repository_for(result[‘uri’]),{}, true) %> <li class=“result”> <%= icon_for result[“primary_type”] %> <% if result[“primary_type”] ===“subject” %> <%= link_to result[“title”], {“filter_term” => search_data.facet_query_string(“subjects”, result[“title”])} %> <% elsif [“agent_person”,“agent_software”,“agent_family”,“agent_corporate_entity”].include?(result[“primary_type”]) %> <%= link_to result[‘title’], :controller => :records, :action => :agent, :id => id, :agent_type => result[“primary_type”] %> <% elsif result[“primary_type”] ===“repository” %> <%= link_to result[‘title’], :controller => :search, :action => :repository, :repo_id => id %> <% else %> <%= link_to title_or_finding_aid_filing_title( result ) , :controller => :records, :action => result[“primary_type”], :id => id, :repo_id => repo_id %> <% end %> <%= render_aspace_partial :partial =>“search/result_summary_#{result[“primary_type“]}”, :locals => {:obj => result} %> </li> <% end %> <%= render_aspace_partial :partial =>“search/pagination”, :locals => {:search_data => search_data} %> |
search_controller.rb
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
require ‘advanced_query_builder’
class SearchController < ApplicationController DETAIL_TYPES = [‘accession’, ‘resource’, ‘archival_object’, ‘digital_object’, VIEWABLE_TYPES = [‘agent’, ‘repository’, ‘subject’] + DETAIL_TYPES FACETS = [“repository”,“primary_type”,“subjects”,“source”,“linked_agent_roles”]
def search @search_data = Search.all(@criteria, @repositories) respond_to do |format| def advanced_search @search_data = Search.all(@criteria, @repositories) render“search/results” def repository if params[:repo_id].blank? return render“search/results” @repository = @repositories.select{|repo| JSONModel(:repository).id_for(repo.uri).to_s === params[:repo_id]}.first @breadcrumbs = [ @search_data = Search.repo(@repository.id, @criteria, @repositories) render“search/results” private def set_search_criteria @criteria[“page”] ||= 1 if @criteria[“filter_term”] if params[:type].blank? @criteria[‘exclude[]’] = params[:exclude] if not params[:exclude].blank?
def set_advanced_search_criteria terms = (0..2).collect{|i| if term and term[“op”] ===“NOT” term if not terms.empty? def search_term(i) end |
application_helper.rb
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
module ApplicationHelper
def include_theme_css def set_title(title) def title_or_finding_aid_filing_title(resource) end def icon_for(type) def label_and_value(label, value) label = content_tag(:dt, label) label + value def i18n_enum(jsonmodel_type, property, value) property_defn = JSONModel(jsonmodel_type).schema[“properties”][property] return if property_defn.nil? if property_defn.has_key?“dynamic_enum” def params_for_search(opts = {}) search_params[“filter_term”] = Array(opts[“filter_term”] || params[“filter_term”]).clone search_params[“sort”] = opts[“sort”] || params[“sort”] search_params[“q”] = opts[“q”] || params[“q”] search_params[“format”] = params[“format”] search_params[“page”] = opts[“page”] || params[“page”] || 1 if opts[“type”] && opts[“type”].kind_of?(Array) search_params[“term_map”] = params[“term_map”] # retain any advanced search params (0..2).each do |i| search_params.reject{|k,v| k.blank? or v.blank?} def set_title_for_search if @search_data facets_to_display = [] if @search_data.query? if @search_data.filtered_terms? if facets_to_display.length > 0 set_title(title) def truncate(string, length = 50, trailing = ‘…’) “#{string[0..50]}#{trailing}”.html_safe
# See: ApplicationController#render_aspace_partial def proxy_localhost? end |
- 我建议截断您的帖子,删除日志中的消息,甚至是与当前问题无关的代码。您的文件很长,在 gist 或 pastebin 中可能会更好。
- 此外,请记住,您仍然可以在视图和控制器中添加记录器语句!这将有助于确定对象是否为零。
我明白了。看起来一些导入的数据有空白标题”。通过更新它们,它能够工作。
错误在你的 _inline_results.html.erb…
1
2 |
<% elsif result[“primary_type”] ===“repository” %>
<%= link_to result[‘title’], :controller => :search, :action => :repository, :repo_id => id %> |
错误是结果[‘title’] 为 nil。所以,添加这行代码….
1
2 3 4 |
<% elsif result[“primary_type”] ===“repository” %>
<% if !result[‘title’].blank? %> <%= link_to result[‘title’], :controller => :search, :action => :repository, :repo_id => id %> <% end %> |
- 这似乎不能解决问题。我仍然得到同样的错误。
来源:https://www.codenong.com/31166494/