Sha256: 867bd5062fdb84d887d2ea0f25001551ec348e90eb39da2d7f2919867e9f6baf

Contents?: true

Size: 960 Bytes

Versions: 14

Compression:

Stored size: 960 Bytes

Contents

module UserHelper

 def devise_error_messages!
    flash_alerts = []
    error_key = 'errors.messages.not_saved'

    if !flash.empty?
      flash_alerts.push(flash[:error]) if flash[:error]
      flash_alerts.push(flash[:alert]) if flash[:alert]
      flash_alerts.push(flash[:notice]) if flash[:notice]
      error_key = 'devise.failure.invalid'
    end

    return "" if resource.errors.empty? && flash_alerts.empty?
    errors = resource.errors.empty? ? flash_alerts : resource.errors.full_messages

    messages = errors.map { |msg| content_tag(:li, msg) }.join
    sentence = I18n.t(error_key, :count    => errors.count,
                                 :resource => resource.class.model_name.human.downcase)

    html = <<-HTML
    <div id="error_explanation">
      <h2>#{sentence}</h2>
      <ul>#{messages}</ul>
    </div>
    HTML

    html.html_safe
  end

  def field_types
    FormFieldType.sys(_sid).where(:hidden=>0).order(:name).all
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kit_cms-2.3.20 app/helpers/user_helper.rb
kit_cms-2.3.19 app/helpers/user_helper.rb
kit_cms-2.3.18 app/helpers/user_helper.rb
kit_cms-2.3.17 app/helpers/user_helper.rb
kit_cms-2.3.16 app/helpers/user_helper.rb
kit_cms-2.3.15 app/helpers/user_helper.rb
kit_cms-2.3.14 app/helpers/user_helper.rb
kit_cms-2.3.13 app/helpers/user_helper.rb
kit_cms-2.3.11 app/helpers/user_helper.rb
kit_cms-2.3.10 app/helpers/user_helper.rb
kit_cms-2.3.9 app/helpers/user_helper.rb
kit_cms-2.3.8 app/helpers/user_helper.rb
kit_cms-2.3.7 app/helpers/user_helper.rb
kit_cms-2.3.6 app/helpers/user_helper.rb