I am wondering what is the best practice for displaying flash messages. The two main ways I've seen use something like this code generated by the scaffold.
<p id="notice"><%= notice %></p>
or placing code in the application header.
<% if !flash.empty? %> <div id="flash"> <% flash.keys.each do |k| %> <div class="<%= k %>"> <%= flash[k] %> </div> <% end %> </div> <% end %>
It seems to me that the first method improves flexibility, while the latter improves code readability and eliminates redundancy. Is there a method that most rails developers prefer? How is the question of how scaffolding implemented? Is it just an assistant that accesses the flash hash? Why worry about using an assistant when you can directly use hash flash? Thanks
ruby-on-rails ruby-on-rails-3
Steve Feb 22 '12 at 7:35 2012-02-22 07:35
source share