Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialWilson Usman
35,206 PointsWhy am I getting two flash messages at the top?
Why I do any of the tasks at the top of the page I get the message repeated. One of the messages is always displaying a notice, even though it should be a success message.
Anything suggestions? I've even gone through the project files and pasted them over my code to see if it was some error I missed somewhere, but I can't seem to find the mistake.
3 Answers
Maciej Czuchnowski
36,441 PointsSo your show.html.erb has this line:
<p id="notice"><%= notice %></p>
Just remove it and it should work properly now :)
Wilson Usman
35,206 PointsThank you for the help. Couldn't have done it without you.
Wilson Usman
35,206 PointsHere's the todo list page, it's basically the same thing on any page. (I got this from chrome dev tools)
<body>
<div class="alert flash notice">
Todo list was successfully updated.
</div>
<p id="notice">Todo list was successfully updated.</p>
<p>
<strong>Title:</strong>
hello
</p>
<p>
<strong>Description:</strong>
what up though friend
</p>
<a href="/todo_lists/8/edit">Edit</a> |
<a href="/todo_lists">Back</a>
</body></html>
Here's the application.html.erb layout page
<body>
<% flash.each do |type, message| %>
<div class="alert flash <%= type %>">
<%= message %>
</div>
<% end %>
<%= yield %>
</body>
</html>
Maciej Czuchnowski
36,441 PointsOK, can you show me your whole project on github or bitbucket? I can usually diagnose things when I see the whole thing and test it locally on my machine.
Wilson Usman
35,206 PointsI just pushed it https://github.com/wilsonusman/Odot
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsPlease post the code of your views that contain the flash message code (templates) as well as views that show you double flashes. The answer has to be there :)