Reputation: 135
I am confused with this error. I am new to rails and I can't figure it out.
<% flash.each do |name,msg| %>
<div class='alert alert-<%="#{name}"%>' >
<a href="#" class='close' data-dismiss='alert' × ></a>
<%= content_tag :div , msg, :id => "flash_#{name}" if msg.is_a?(String); %>
</div>
<% end %>
Error message is:
syntax error, unexpected ')' if msg.is_a?(String); );@output_buffer.safe_append=' ^ /home/mody/Desktop/rails_apps/testing/app/views/layouts/application.html.erb:51: syntax error, unexpected keyword_ensure, expecting ')' /home/mody/Desktop/rails_apps/testing/app/views/layouts/application.html.erb:53: syntax error, unexpected keyword_end, expecting ')'
Upvotes: 0
Views: 687
Reputation: 8900
Lots of syntactical problems here. Change your line to the following:
<%= content_tag(:div, msg, {:id => "flash_#{name}"}) if msg.is_a?(String) %>
content_tag
arguments inside of parentheses to ensure that Ruby does not get confused when introducing the if
conditionUpvotes: 1