0

My application has two parts. In one part work without layout. In top of the controller has a line layout false. I want to display a flash message in my view when submit my form. but in all flash message tutorials used layout application.html file but in my case i'll not use layout. appreciate your ideas

1 Answers1

0

You can use that in two ways

One You can use that inside page, which working without layout like

On the top of the page and every page which you need show flash

# page.html.erb
<% flash.each do |msg| %>
    <%= msg %>
<% end %>
OR
<% if alert.present? %> # or :notice
   <%= alert %>
<% end %>

Two This way is more generic like you can create a folder inside view and named common inside this create partial file and named _flash.html.erb

# view/common/_flash.html.erb
<% flash.each do |msg| %>
    <%= msg %>
<% end %>
OR
<% if alert.present? %> # or :notice
   <%= alert %>
<% end %>

and finally, you can render this on your file which needs to show the message like

On the top of the page and every page which you need show flash

<%= render partial: "common/flash" %>

Hope to help

fool-dev
  • 7,671
  • 9
  • 40
  • 54