Skip to content

Instantly share code, notes, and snippets.

@taylorbrooks
Created July 13, 2012 21:19
Show Gist options
  • Save taylorbrooks/3107549 to your computer and use it in GitHub Desktop.
Save taylorbrooks/3107549 to your computer and use it in GitHub Desktop.
Error Messages Helper for Bootstrap
# app/helpers/application_helper.rb
def twitterized_type(type)
case type
when :alert
"alert-block"
when :error
"alert-error"
when :notice
"alert-info"
when :success
"alert-success"
else
type.to_s
end
end
@denzuko
Copy link

denzuko commented Jul 24, 2012

oddely enough my views do now find this, how do we fix?

@taylorbrooks
Copy link
Author

If you're using HAML, make sure your flash is referencing the twitterized_type in the class.

1  - flash.each do |type, message|
2   .alert.fade.in{ "data-alert" => "alert", :class => twitterized_type(type) }
3      %a.close{href: "#", data: {dismiss: 'alert'}} ×
4      %h4= message

@denzuko
Copy link

denzuko commented Jul 31, 2012

Pardon me for the curt and improper english; Twenty hour coding sessions, 64oz of coffee, and an over heating laptop does not make for a very good combination.

Thanks for showing me the HAML code, might help on another app. But, in all actuality, I was using ERB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment