Rails Flash.now not working

后端 未结 5 881
-上瘾入骨i
-上瘾入骨i 2020-12-23 16:56

I have a view from which I make an ajax request to the controller and after the action is successfully completed I initialize the flash.now[:notice]. But af

5条回答
  •  时光说笑
    2020-12-23 17:54

    code in the controller:

    flash[:success] = "All good!"
    format.html { redirect_to some_path}
    

    and in the view with close button:

    <% flash.each do |key, value| %>
     <%= content_tag(:div, class: "alert alert-#{key} alert-dismissable") do %>
      <%= value %>
         
     <% end %> 
    <% end %>
    

提交回复
热议问题