Skip to content

Loading…

Fixing a 1.9.2 incompatibility in macros.rb #2

Closed
wants to merge 1 commit into from

4 participants

@ryana

Hey John,

Ran into this and forgot to issue a pull request. Someone else (zbelzer) just ran into it. Ruby 1.9.2 forces us to be explicit in lambda arity now. Thanks!

@zbelzer

Can you get a pull request for this in nunemaker's fork? I was just about to make the same change when I found yours.

Sure.

Sweet. Think any additional tests are necessary?

@ryana

To be honest, I don't know :) I never ran the tests on validatable. I just saw the issue manifest itself in my application tests and knew it was a safe fix. #badryan

@zbelzer

http://www.ruby-forum.com/topic/213325 Was my reference to see what the correct behavior of lambdas should be. Interesting that it 'went away' for a while.

@xaviershay

+1 on this fix, I needed it.

@xaviershay

Still need this, for the record.

@jnunemaker jnunemaker closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 28, 2011
  1. @ryana

    1.9.2 shenanigans

    ryana committed
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/validatable/macros.rb
View
4 lib/validatable/macros.rb
@@ -286,12 +286,12 @@ def include_validations_from(attribute_to_validate, options = {})
# * map - A hash that maps attributes of the child to attributes of the parent.
# * if - A block that when executed must return true of the validation will not occur.
def include_errors_from(attribute_to_validate, options = {})
- children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda { true })
+ children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda {|*x| true })
end
def include_validations_for(attribute_to_validate, options = {}) #:nodoc:
puts "include_validations_for is deprecated; use include_errors_from instead"
- children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda { true })
+ children_to_validate << ChildValidation.new(attribute_to_validate, options[:map] || {}, options[:if] || lambda {|*x| true })
end
# call-seq: before_validation(&block)
Something went wrong with that request. Please try again.