我不知道Ruby,但我的应用程序遇到了这个问题。有人可以帮帮我吗?
第7行
上的ActionView :: TemplateError(无法将nil转换为String)
4: <h3><span><%= opinion.opinion %></span>: <%= opinion.keywords.sort.join(' / ').upcase %> </h3>
5: <div class="original">Estado original: <span class="pos"><%= opinion.opinion %></span></div>
6: <%#= highlight(simple_format(highlight_ontology(opinion)), opinion.keywords, :highlighter => '<em>\1</em>') %>
7: <%= simple_format(highlight_ontology(opinion)) %>
8: <%= button_to_remote('POSITIVO', {:url => url_for(opinion), :method => :put, :with => '"opinion[opinion]=POSITIVE"' }, :class => :positive) %>
9: <%= button_to_remote('OBJETIVO', {:url => url_for(opinion), :method => :put, :with => '"opinion[opinion]=OBJECTIVE"' }, :class => :objective) %>
10: <%= button_to_remote('NEGATIVO', {:url => url_for(opinion), :method => :put, :with => '"opinion[opinion]=NEGATIVE"' }, :class => :negative) %>
谢谢!
答案 0 :(得分:17)
使用(variable || "")
而不仅仅是变量应该使其默认为空字符串。
此技术称为null(或nil)合并。