gpt4 book ai didi

ruby - 无法将 nil 转换为字符串

转载 作者:数据小太阳 更新时间:2023-10-29 06:48:43 25 4
gpt4 key购买 nike

我不了解 Ruby,但我的应用程序遇到了这个问题。有人可以帮助我吗?

ActionView::TemplateError (can't convert nil into String) on line #7

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) %>

谢谢!

最佳答案

使用 (variable || "") 而不仅仅是变量应该使其默认为空字符串。

这种技术称为 null(或 nil)合并。

关于ruby - 无法将 nil 转换为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8852264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com