当表单提交时,将显示flash消息,并且用户将保留所有字段的相同页面。如果删除了其中一个必填字段,然后再次提交表单,则不会显示错误,并显示flash: filled.Now is displayed.When I off.unable the page the notice off.unable to找出.i提供视图代码和控制器的原因
flash[:notice] = "Saved Successfully"查看代码:
<b><h3><%= flash[:notice] %></h3></b>
<% semantic_form_for(@featured_business, {:url => "#{@signin_link}".gsub(/\/+/, '/'), :html => {:multipart => true, :class => 'validate business'}}) do |f| %>
<% f.inputs do %>
<%= hidden_field_tag 'more_validations_required' %>
<%= f.input :name, :label => ' Name:' , :input_html => { :style => "width:240px;" }%>
<%= f.input :contact_name, :label => 'Contact name:',:required => false, :input_html => { :style => "width:240px;" } %>
<%= f.input :phone, :label => 'Phone Number:', :input_html => { :style => "width:240px;" } %>
<%= f.input :email, :label => 'Email:', :input_html => { :class => 'email' } , :input_html => { :style => "width:240px;" } %>
<%= f.commit_button :label => "", :button_html => {:class => 'signup business'} %>
<% end %><%结束%>
发布于 2011-08-25 18:35:11
闪光消息仅存在于下一页。如果刷新页面,则闪光消息将不再存储在会话中。
这里有一篇很好的博客文章,可以帮助你理解flash消息。http://travisonrails.com/2008/08/17/working-with-the-flash-hash
https://stackoverflow.com/questions/7188782
复制相似问题