Skip to content

Instantly share code, notes, and snippets.

View mdepolli's full-sized avatar

Marcelo De Polli mdepolli

  • Shore GmbH
  • Munich, Germany
View GitHub Profile
@mdepolli
mdepolli / gist:3674398
Created September 8, 2012 12:27
Titleize equivalent for pt-BR
def br_titleize(word)
humanize(underscore(word)).gsub(/(?!(?<= )(de|da|do|das|dos|d'|e|a|o)\b)(\b[a-z\u00E0-\u00FC])/) { |s| s.mb_chars.capitalize.to_s }
end
@mdepolli
mdepolli / application_helper.rb
Last active October 10, 2015 08:27
Bootstrap 2.1-compatible flash messages helper
def flash_message
types = { :notice => 'info', :success => 'success', :error => 'error', :alert => 'error' }
flash.inject("") do |sum, message|
content_tag :div, :class => "alert alert-#{types[message[0]]}" do
button_tag('&#215;'.html_safe, :type => 'button', :class => 'close', :'data-dismiss' => 'alert', :name => nil) +
message[1]
end
end
end