Die*_*ios 1 ruby ruby-on-rails erb
有问题的代码:
<%= if flash[:notice] %>
<div class="notification is-primary global-notification">
<p class="notice"><%= notice %></p>
</div>
<% end %>
<%= if flash[:alert] %>
<div class="notification is-danger global-notification">
<p class="alert"><%= alert %></p>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
已将语法更改为:if (flash[:notice])。但是,还是放下这个。任何的想法?
<%= if flash[:notice] %>
Run Code Online (Sandbox Code Playgroud)
上面的代码应该是:
<% if flash[:notice] %>
Run Code Online (Sandbox Code Playgroud)
笔记
<% %> - 执行括号内的 ruby 代码。
<%= %> - 将某些内容打印到 ERB 文件中。