I have this code for displaying flash messages in a HAML file:
# View partial
Test1
= flash.each do |type, message|
.container
.row
.col-md-12
%div{class: "alert #{bootstrap_class_for(type)} alert-dismissible", role: 'alert'}
Test1a
= message
Test1b
%button.close{:'data-dismiss' => 'alert', type: 'button'}
%span{:'aria-hidden' => 'true'} ×
%span.sr-only Close
Test2
I can't understand why between Test1b and Test2 a plain Hash gets displayed.
Here's some more code in case that helps:
# Helpers
# http://stackoverflow.com/questions/4101641/rails-devise-handling-devise-error-messages
module DeviseHelper
def devise_error_messages!
if resource.errors.full_messages.any?
flash.now[:error] = resource.errors.full_messages.join(' & ')
end
return
end
end
module ApplicationHelper
# https://gist.github.com/roberto/3344628
def bootstrap_class_for flash_type
case flash_type.to_sym
when :success
"alert-success"
when :error
"alert-danger"
when :alert
"alert-warning"
when :notice
"alert-info"
else
flash_type.to_s
end
end
end
# view
.container-fluid
.row
.full-width-background.form-page
.col-md-4.col-md-offset-4
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-page'}) do |f|
= devise_error_messages!
.form-group
= f.label :email
= f.email_field :email, autofocus: true, class: 'form-control'
.form-group
= f.label :password
- if @validatable
%i #{@minimum_password_length} characters minimum
= f.password_field :password, autocomplete: 'off', class: 'form-control'
.form-group
= f.label :password_confirmation
= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control'
.form-group
= f.submit 'Sign up', class: 'btn btn-primary'
= render 'devise/shared/links'