Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from anonymous/application_helper.rb
Created May 7, 2013 00:36
Show Gist options
  • Save radar/5529441 to your computer and use it in GitHub Desktop.
Save radar/5529441 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def full_title(page_title)
base_title = "Vende Comigo"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<i class="icon-remove icon-large"></i>
#{messages}
</div>
HTML
html.html_safe
end
def display_messages
flash.each do |name, message|
if message.is_a?(String)
case name
when :error
text = "#b94a48"
when :warning
text = "#c09853"
when :success
text = "#468847"
when :info
text = "#3a87ad"
else
text = "white"
end
concat(<<-HTML
<div class="alert alert-error alert-block">
<i class="icon-remove icon-large"></i>
#{message}
</div>
HTML
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment