You haven't made any mistakes and by creating a helper, you're reducing the amount of code required to do common things which is great for testing and organization.
One suggestion that I have is that you change your setup and make a shared partial to display the code so it's easier to manage. Then have your helper method just proxy the arguments to the partial function call.
First setup your partial (save it as shared/_flash_messages.html.erb):
<div class="flash-messages">
<% if messages && messages.length > 0 %>
<% messages.each do |key, message| %>
<div id="<%= key %>" class="flash"><%= message %></div>
<% end %>
<% else %>
No Messages to display
<% end %>
</div>
Then setup your helper methods:
def register_flash_message(key,message)
flash[key]=message
end
def display_flash_messages()
render 'shared/flash_messages', :messages => flash
end
This will make things much easier to maintain and customize. You also won't have to deal with having to build your HTML inside of Ruby since everything's stored inside of a partial.