使用image_tag时,提供的Nil位置出现参数错误。如何使image_tag仅在存在相应图像时才显示的位置为可选?这是与Ruby on Rails 5一起使用的。
这是我当前的显示页面视图:
<p id="notice"><%= notice %></p>
<%= image_tag @restaurant.image_url %>
<p>
<strong>Name:</strong>
<%= @restaurant.name %>
</p>
<p>
<strong>Address:</strong>
<%= @restaurant.address %>
</p>
<p>
<strong>Phone:</strong>
<%= @restaurant.phone %>
</p>
<p>
<strong>Website:</strong>
<%= @restaurant.website %>
</p>
<%= link_to 'Edit', edit_restaurant_path(@restaurant), class: 'btn btn-link' %> |
<%= link_to 'Back', restaurants_path, class: 'btn btn-link' %>
Run Code Online (Sandbox Code Playgroud) @Then("a topic is (not) displayed on the chat icon of the menu")
Run Code Online (Sandbox Code Playgroud)
基本上我希望如果可能的话不要是可选的?以前是(是|不是)。
添加 is|is not 是捕获组的一部分,在 stepdef 中作为字符串输入。