This is my first project using Ruby on Rails and I'm working on the front-end code; the back-end developer is new to rails too. One template includes the code render 'flashes'
, which is triggered when there is an error on a form submission; but the markup it generates is messed up, and I'd like to fix it. Here's an example. The <!-- comments -->
are mine:
<div id="flash">
<div class="wrapper">
<div title="Error" class="error"></div> <!-- Empty div -->
<p>Please enter a valid email</p> <!-- p element sibling of div.error -->
</div> <!-- Closes div.wrapper -->
</div> <!-- Closes div#flash -->
</div> <!-- Extra /div closes parent div -->
I would prefer to use one div
for the message, but the biggest problem is the extra closing div
tag at the end, which closes a parent division, messing up the layout.
I see that the error message is defined in the controller as flash[:error] = "Please enter a valid email"
, but I don't know where rails is getting this bogus markup. Is there a _flashes
partial I can edit to fix this problem? I've pored over the project's filesystem, and it's not clear to me where this markup lives.
There is no _flashes.html.erb
file in the Rails source. If you're seeing
render 'flashes'
in your application, you or some generator you ran put it there. Look through the files in app/views/
for one called _flashes.html.erb
that contains the markup you provided in your Question. Once you find that file you should be able to modify it however you need to fix your broken HTML issue.
If you can't find it there, look at your list of gems in your Gemfile
, specifically for one that relates to theming/templating. It's possilbe you've included a gem that contains this template file (though much less likely than the file existing in app/views/
).