Ruby on rails Rails抱怨缺少括号,而我不希望有括号
我得到以下错误:Ruby on rails Rails抱怨缺少括号,而我不希望有括号,ruby-on-rails,ruby,erb,Ruby On Rails,Ruby,Erb,我得到以下错误: Showing app/views/layouts/application.html.erb where line #15 raised: app/views/layouts/application.html.erb:15: syntax error, unexpected keyword_end ');@output_buffer.append= ( end );@output_buffer.safe_concat('
Showing app/views/layouts/application.html.erb where line #15 raised:
app/views/layouts/application.html.erb:15: syntax error, unexpected keyword_end
');@output_buffer.append= ( end );@output_buffer.safe_concat('
^
app/views/layouts/application.html.erb:22: syntax error, unexpected keyword_ensure, expecting ')'
app/views/layouts/application.html.erb:24: syntax error, unexpected keyword_end, expecting ')'
Extracted source (around line #15):
12: <div class="container">
13: <%= flash.each do |key, value| %>
14: <div class="alert alert-<%= key %>"><%= value %></div>
15: <%= end %>
16: <%= yield %>
17: <%= render 'layouts/footer' %>
18: </div>
显示app/views/layouts/application.html.erb,其中第15行出现:
app/views/layouts/application.html.erb:15:语法错误,意外的关键字\u结束
');@输出_buffer.append=(结束)@输出缓冲区安全连接('
^
app/views/layouts/application.html.erb:22:语法错误,意外关键字_sure,应为“')”
app/views/layouts/application.html.erb:24:语法错误,意外关键字_end,应为“')”
提取的源(第15行附近):
12:
13:
14:
15:
16:
17:
18:
下面是application.html.erb的内容
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<%= stylesheet_link_tag "application", media: 'all' %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<%= end %>
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
试试:
试试:
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
<% Ruby code -- inline with output %>
<%= Ruby expression -- replace with result %>
<%# comment -- ignored -- useful in testing %>
% a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
%% replaced with % if first thing on a line and % processing is used
<%% or %%> -- replace with <% or %> respectively