# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  
  def custom_error_messages
    { :header_message => "", :message => "The following problems occurred:" }
  end
  
  def active_if(options)
    if options[:action]
      options[:action].each do |action|
        return "active" if params[:action] == action
      end
    elsif options[:controller]
      options[:controller].each do |controller|
        return "active" if params[:controller] == controller
      end
    else
    end
    return ""
  end
  
  def show_flash_message
    message = ""
    flash.each do |name, msg|
      message += content_tag :div, msg, :id => "flash_#{name}"
    end
    message
  end

  def source_field(options)
    
    if options[:collection]
      return nil if @source.send(options[:attribute]).empty?
    else
      return nil unless @source.send(options[:attribute])
    end
    
    content_tag(:dt, (options[:label] || options[:attribute].to_s.humanize)) +
    content_tag(:dd, (options[:url] ? link_to(options[:value], options[:url]) : options[:value]))
  end
  
  def gravatar_for(user)
    gravatar_image_tag(user.email, :alt => user.display_name, :title => user.display_name, :class => "avatar")
  end
  
  def markdownize(text)
    RDiscount.new(text).to_html
  end

end

# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  
  def custom_error_messages
    { :header_message => "", :message => "The following problems occurred:" }
  end
  
  def active_if(options)
    if options[:action]
      options[:action].each do |action|
        return "active" if params[:action] == action
      end
    elsif options[:controller]
      options[:controller].each do |controller|
        return "active" if params[:controller] == controller
      end
    else
    end
    return ""
  end
  
  def show_flash_message
    message = ""
    flash.each do |name, msg|
      message += content_tag :div, msg, :id => "flash_#{name}"
    end
    message
  end

  def source_field(options)
    
    if options[:collection]
      return nil if @source.send(options[:attribute]).empty?
    else
      return nil unless @source.send(options[:attribute])
    end
    
    content_tag(:dt, (options[:label] || options[:attribute].to_s.humanize)) +
    content_tag(:dd, (options[:url] ? link_to(options[:value], options[:url]) : options[:value]))
  end
  
  def gravatar_for(user, options)
    options.reverse_merge!(:class => "avatar", :size => 64)
    gravatar_image_tag(user.email, :alt => user.display_name, 
                                   :title => user.display_name, 
                                   :class => options[:class],
                                   :width => options[:size],
                                   :height => options[:size],
                                   :gravatar => { :size => options[:size] })
  end
  
  def markdownize(text)
    RDiscount.new(text).to_html
  end

end

Create a helper for displaying gravatars.
Create a helper for displaying gravatars. [Story1567591]