Sha256: 7c417aefb8f3f22d3bd2324f91668fb67e590433b6fd8816681cf967664fcbcb

Contents?: true

Size: 701 Bytes

Versions: 9

Compression:

Stored size: 701 Bytes

Contents

module Erroneous
  
  require 'erroneous/railtie' if defined?(Rails)
  
  mattr_accessor :error_class
  @@error_class = 'error'
  
  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

9 entries across 9 versions & 1 rubygems

Version Path
erroneous-1.0.1 lib/erroneous.rb
erroneous-0.1.1 lib/erroneous.rb
erroneous-0.1.0 lib/erroneous.rb
erroneous-0.0.8 lib/erroneous.rb
erroneous-0.0.7 lib/erroneous.rb
erroneous-0.0.6 lib/erroneous.rb
erroneous-0.0.5 lib/erroneous.rb
erroneous-0.0.4 lib/erroneous.rb
erroneous-0.0.3 lib/erroneous.rb