Diego Palacios
Diego Palacios

Reputation: 23

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: enter image description here

Already changed the syntax to: if (flash[:notice]). But still, drop this. Any idea?

Upvotes: 1

Views: 211

Answers (1)

andsilver
andsilver

Reputation: 5972

<%= if flash[:notice] %>

The above code should be:

<% if flash[:notice] %>

Note

<% %> - Executes the ruby code within the brackets.

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

Upvotes: 6

Related Questions