当没有可用的图像时,指向缩略图的以下链接失败时出现错误。
<%= link_to '', focus_account_product_path(@account, trackable.is_a?(Product) ? trackable : trackable.product, only_available: only_show_available?(params) ), remote: true, class: "full-background-image product-thumbnail #{scale}", style: "background-image: url(" + image + ");" %>
当我隔离这段代码时,我发现问题出在style: "background-image: url(" + image + ");"
行中。删除此选项可以恢复舞台,但也可以剪切图像。
完整的错误日志显示以下内容:
ActionView::Template::Error (no implicit conversion of nil into String):
23: <%= div_for trackable, class: 'inline-block' do %>
24: <% if focus == true %>
25:
26: <%= link_to '', focus_account_product_path(@account, trackable.is_a?(Product) ? trackable : trackable.product, only_available: only_show_available?(params) ), remote: true, class: "full-background-image product-thumbnail #{scale}", style: "background-image: url(" + image + ");" %>
27:
28: <% else %>
29: <%= link_to '', [@account, trackable], class: "full-background-image product-thumbnail #{scale}", style: "background-image: url(" + image + "); display: block;" %>
我不熟悉该错误,尽管它看起来与other cases cited on Stack Overflow非常相似;这个特定的link_to调用的结构是一个症结所在。 在这种情况下可以附加try方法吗?