使用or操作符时,My Ruby if语句失败。为什么IF语句在OR ||时失败用来?
<% if @body_id == 'plants' || 'trees' %>
<meta name="robots" content="noindex, nofollow">
<% end %>
使用or操作符时,My Ruby if语句失败。为什么IF语句在OR ||时失败用来?
<% if @body_id == 'plants' || 'trees' %>
<meta name="robots" content="noindex, nofollow">
<% end %>
你不能使用||
那样,ID做['plants', 'trees'].includes? @body_id
代替。
'%w [植物树]'所有冰雹rubocop –
@dezman - 谢谢! – traci123me
不是吗?
<% if @body_id == 'plants' || @body_id == 'trees' %>
你是什么意思与“失败”,你会得到一个错误?如果是,请包括堆栈跟踪。如果这是意外行为,请添加您的实际和预期行为。 – DarkCygnus