Hello I am new to ruby on rails and I am struggling to understand I18n's flash messages. I am using devise, rails 4, and twitter bootstrap.I understand that devise only uses flash[:notice]
and flash[:alert]
.
I am able to get flash messages working for my user model with signing in and logging out. However I cannot get the flash error for signup or forgot password to display properly. It looks like the default error message.
I've looked at bunch of questions related to this and Im confused on the way to go about displaying all flash messages (errors, successes, notifications) with pretty css.
Perhaps the answer is already in this article right under my nose? rails - Devise - Handling - devise_error_messages
Currently my flash messages are based on How to define Flash Notifications with Twitter Bootstrap Rails gem
Here is my example:
within 'app/views/layouts/application.html.erb'
<%= render 'layouts/messages' %>
'app/views/layouts/_messages.html.erb'
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<a class="close" data-dismiss="alert">×</a>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
</div>
<% end %>
<% end %>
How do I display all flash messages (errors, successes, notifications) using my custom css?
Update: This post displays a correct version of what I am trying to do. The problem I have is that the styling does not look the same. I believe it is because of the html tag.
html = <<-HTML
<div class="alert alert-error alert-block"> <button type="button"
class="close" data-dismiss="alert">x</button>
<h4>#{sentence}</h4>
#{messages}
</div>
HTML
Any idea how I can have the same styling for the alerts? or what tags to use in the css?
You can see the difference between the sign up^^ and sign in (below) pages.