导轨通知没有出现

我在使用Bootstrap的Rails 4中

这是我在我的控制器中的创建操作:

def create @contest = Contest.new(contest_params) if @contest.save flash[:notice] = "Contest saved successfully" redirect_to @contest else redirect_to root_path, :notice => 'Project not saved' end end 

提交表格时怎么没有通知? 有什么我想念的吗? 我是一个初学者,但却无法弄清楚这一点。

我的布局中已经有以下内容:

   

试试这样:

  flash[:notice] = 'Project saved successfully' redirect_to about_path 

在某些版本中,重定向闪存已被破坏。 如果您想尝试解决方法:

 redirect_to url, :flash => { :notice => "notice" } 

还可以编辑你的布局

如果发生冲突,请删除布局标题。

   

<%= flash[:notice] %>

<%= flash[:alert] %>

<%= yield %> <%= render 'layouts/footer' %>

了解闪光灯 。 您必须在html视图中显示Flash内容,最好是在布局中。

   <% flash.each do |name, msg| -%> <%= content_tag :div, msg, class: name %> <% end -%>   

在html视图的root_path中设置<%= flash[:notice] %>