简体   繁体   English

<%= if flash[:notice]%> 中的语法错误 Ruby on Rails

[英]Syntax error in <%= if flash[:notice]%> Ruby on Rails

The probleming code:有问题的代码:

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

And when running my server the following error drops:并且在运行我的服务器时出现以下错误: 在此处输入图像描述

Already changed the syntax to: if (flash[:notice]) .已经将语法更改为: if (flash[:notice]) But still, drop this.但是,还是放下这个。 Any idea?任何的想法?

<%= if flash[:notice] %>

The above code should be:上面的代码应该是:

<% if flash[:notice] %>

Note笔记

<% %> - Executes the ruby code within the brackets. <% %> - 执行括号内的 ruby 代码。

<%= %> - Prints something into ERB file. <%= %> - 将某些内容打印到 ERB 文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM