require 'html_helper' module ApplicationHelper include HtmlHelper def display_standard_flashes(message = 'There were some problems with your submission:') if flash[:notice] flash_to_display, level = flash[:notice], 'notice' elsif flash[:warning] flash_to_display, level = flash[:warning], 'warning' elsif flash[:error] level = 'error' if flash[:error].instance_of? ActiveRecord::Errors flash_to_display = message flash_to_display << activerecord_error_list(flash[:error]) else flash_to_display = flash[:error] end else return end content_tag 'div', flash_to_display, :class => "flash #{level}" end def activerecord_error_list(errors) error_list = '' error_list end def plugin_meta(label, attribute, opts={}) return if attribute.to_s.empty? opts.reverse_merge!(:link => false, :html => {}) unless attribute.blank? if opts[:link] content_tag('li', content_tag('span', label, :class => 'label') << '
' << content_tag('a', attribute, :href => attribute), opts[:html]) else content_tag('li', content_tag('span', label, :class => 'label') << '
' << attribute.to_s, opts[:html]) end end end def plugin_install_tool_name 'RaPT' end def labelled_form_field(object, attribute, label_text, form_field, helper_text = nil) label_content = label_text label_content << error_list_for(object, attribute) if object.errors.on(attribute) label = content_tag('label', label_content) field = form_field << tag('br') helper = ''; helper << content_tag('span', helper_text, :class => 'field_helper') unless helper_text.nil? label << field << helper end def error_list_for(object, attribute) error_list = object.errors[attribute].collect { |e| content_tag('li', Inflector::humanize(attribute.to_s) + " " + e) } content_tag('ul', error_list, :class => 'field_errors') end end