This might be an easy one for you guys, but I’m not sure the best way to achieve it.
Is there some type of .erb I can write that asks “If :notice is present, then render…”?
Here’s more about the issue:
My controller specifies a :notice for both the create and update actions (pretty standard). When I load the pages, the notices do as I’d expect and show up. When I reload the page however, (not sure why someone would do this, but I did), the :notice goes away (great, that’s what I want), but the containing <div> remains.
How do I go about ensuring that the encapsulating <div> is removed along with the :notice? I’m not sure what conditionals to specify in my view or maybe controller. The view looks something like this (btw, I’m using Twitter Bootstrap JS alerts).
View
<div class="alert-message success fade in" data-alert="alert">
<a class="close" href"#">×</a>
<p><%= notice %></p>
</div>
My controller is a single scaffolded model/resource with basic structure
What I did was:
Not sure if this is the most efficient and “Rails-y” way to do it, but it worked for me.