Reputation: 680
In my application I am using Bootstrap flash in my header to show all notices/alerts.
Here is my code:
.col-md-8.col-md-offset-2
= bootstrap_flash
.clearfix
.row
= yield
I have a vote controller that I would like to show its alert in completely different place, next to the vote button itself.
How can I "choose" where a specific notice from specific controller will be shown?
Upvotes: 0
Views: 78
Reputation: 2424
Here is a HAML way. Just copying the @David answer with haml.
If you change your layout to:
.col-md-8.col-md-offset-2
= bootstrap_flash unless content_for?(:custom_flash)
And in the view for your form you put:
- content_for(:custom_flash) do
= bootstrap_flash
And by the button you do:
= yield(:custom_flash)
This way your normal flashes will be shown unless you define a content_for(:custom_flash)
Upvotes: 1
Reputation: 1228
(I do not know this fancy HAML-thingy ;) )
If you change your layout to:
<div class="col-md-8 col-md-offset-2">
<% unless content_for?(:custom_flash) do %>
<%= bootstrap_flash %>
<% end %>
</div>
And in the view for your form you put:
<% content_for(:custom_flash) do %>
<%= bootstrap_flash %>
<% end %>
And by the button you do:
<%= yield(:custom_flash) %>
This way your normal flashes will be shown unless you define a content_for(:custom_flash)
.
I hope you can solve the .erb
, or perhaps someone can help me to do it in HAML ;)
Upvotes: 0