Orbit/app/helpers/application_helper.rb

32 lines
732 B
Ruby
Raw Normal View History

2009-05-07 16:53:18 +00:00
module ApplicationHelper
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
def colorize_in_use_locale(locale)
@site_in_use_locales.include?(locale)? 'green' : 'red'
end
def flash_messages
return unless messages = flash.keys.select{|k| FLASH_NOTICE_KEYS.include?(k)}
formatted_messages = messages.map do |type|
content_tag :div, :class => type.to_s do
message_for_item(flash[type], flash["#{type}_item".to_sym])
end
end
raw(formatted_messages.join)
end
def link_back
link_to t('back'), session[:last_page]
end
def message_for_item(message, item = nil)
if item.is_a?(Array)
message % link_to(*item)
else
message % item
end
end
2009-05-07 16:53:18 +00:00
end