Sha256: aed7fa7ff47243f0f2143b8aa268c58074d08c8a51696b98b053787e130c2610

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

module Erroneous
  
  require 'erroneous/railtie' if defined?(Rails)
  
  mattr_accessor :error_class
  @@error_class = 'errors'
  
  mattr_accessor :error_tag
  @@error_tag = :div
    
  # Output basic sentence errors.
  #
  # Usage:
  #
  #   <%= errors(@user, :name) %>
  #
  # Equivalent:
  #
  #   <%- if @user.errors[:name] -%>
  #     <%= content_tag(:div, :class => 'errors' ) do %>
  #       <%= @user.errors[:name].to_sentence %>
  #     <% end %>
  #   <%- end -%>
  
  def errors(object, method, options = {})
    if object.errors[method]
      content_tag(::Erroneous.error_tag, :class => ::Erroneous.error_class) do
        object.errors[method].to_sentence
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
erroneous-0.0.2 lib/erroneous.rb
erroneous-0.0.1 lib/erroneous.rb