[英]Getting an error on Ruby on Rails Flash
I'm using the following code to display the contents of the flash object in Rails: 我正在使用以下代码在Rails中显示Flash对象的内容:
<%= flash.each do |k, v| %>
<div class="flash <%= k %>"><%= v %></div>
<% end %>
Instead of showing just the message (or lack there of) it gives me the contents of the flash hash: 不仅显示消息(或不显示消息),它还为我提供了Flash哈希的内容:
{:error=>"Invalid email/password combination."}
or just this if there is no flash object created 如果没有创建Flash对象,则仅此一个
{}
Is there something wrong in my Rails code, or perhaps something wrong in my Apache setup (it doesn't appear when I push to Heroku)? 我的Rails代码中有什么问题,或者我的Apache设置中有什么问题(当我按下Heroku时没有出现)?
Try this (with <%
instead of <%=
for the each loop): 尝试以下操作(每个循环使用
<%
而不是<%=
):
<% flash.each do |k, v| %>
<div class="flash <%= k %>"><%= v %></div>
<% end %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.