Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Deleting Todo Items

Wilson Usman
Wilson Usman
35,206 Points

Why 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.

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

Please 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 :)

3 Answers

Maciej Czuchnowski
Maciej Czuchnowski
36,437 Points

So your show.html.erb has this line:

<p id="notice"><%= notice %></p>

Just remove it and it should work properly now :)

Wilson Usman
Wilson Usman
35,206 Points

Thank you for the help. Couldn't have done it without you.

Wilson Usman
Wilson Usman
35,206 Points

Here'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
Maciej Czuchnowski
36,437 Points

OK, 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.