Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 15 additions and 0 deletions.
  1. +1 −0  init.rb
  2. +14 −0 lib/errors.rb
View
1  init.rb
@@ -0,0 +1 @@
+require File.join(File.dirname(__FILE__),'lib','validatable')
View
14 lib/errors.rb
@@ -5,6 +5,20 @@ class Errors
def_delegators :errors, :clear, :each, :each_pair, :empty?, :length, :size
+ # Returns true if the specified +attribute+ has errors associated with it.
+ #
+ # class Company < ActiveRecord::Base
+ # validates_presence_of :name, :address, :email
+ # validates_length_of :name, :in => 5..30
+ # end
+ #
+ # company = Company.create(:address => '123 First St.')
+ # company.errors.invalid?(:name) # => true
+ # company.errors.invalid?(:address) # => false
+ def invalid?(attribute)
+ !@errors[attribute.to_sym].nil?
+ end
+
# call-seq: on(attribute)
#
# * Returns nil, if no errors are associated with the specified +attribute+.

No commit comments for this range

Something went wrong with that request. Please try again.