简体   繁体   中英

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]) . 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.

<%= %> - Prints something into ERB file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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