ActiveRecord::Validations::ClassMethods.evaluate_condition missing in Rails 2.1.0?

Hi,

I have trustfully updated my Rails-Application from 2.0.2 to 2.1.0 and
stumbled over
the fact, that a public interface method simply has disappeared!

I use a custom validation I wrote myself which gets mixed into
Activerecord::Base.
The validation uses the class method ‘evaluate_condition’ of
ActiveRecord::Validations::ClassMethods.
This worked fine as of rails 2.0.2;
Now I get the error ‘method not found’ when I use the validation. The
method really does not exist anymore.

I use the method as suggested in many places for the evaluation
the :if-clause of my validator.

Is there any replacement for this method? How do I solve this problem?

And also some general questions:
How can it be that interface methods get silently deleted in a minor
release step ??
And, even worse, not document it anywhere or provide a way for the
user to bring their source up to date ??
I have searched myself silly, and not found any hint on this issue…

Am I the only one running into that?
I can hardly believe that…

Thank you for helping,

Regards,
Jörg

On Jun 25, 12:27 pm, StYerk [email protected] wrote:

This worked fine as of rails 2.0.2;
Now I get the error ‘method not found’ when I use the validation. The
method really does not exist anymore.

Refactored into ActiveSupport::Callbacks. Looks like more of an
implementation detail to me, it’s unfortunate it was ever public
(given that there were no tests for that specific function it doesn’t
look like it was intended as a public interface).

Fred

user to bring their source up to date ??
I have searched myself silly, and not found any hint on this issue…

Am I the only one running into that?
I can hardly believe that…

Thank you for helping,

Regards,
J

On 25 Jun 2008, at 14:57, StYerk wrote:

But since I have seen this method being used in many examples for
custom made validators
this refactoring should be documented somewhere and how people have to
rewrite their code.

How do I have to rewrite my validator now?

I’d have a look at what other validations do. When you’ve got your
head around it write it up somewhere :slight_smile:

Fred

Hi Fred,

Thank you for your fast answer!

Actually, the scope in which I use it is in a validator that gets
mixed into
ActiveRecord::Base, so actually it would not even need to be public
(Am I wrong?).
But since I have seen this method being used in many examples for
custom made validators
this refactoring should be documented somewhere and how people have to
rewrite their code.

How do I have to rewrite my validator now?

Here’s what I used with 2.0.2:

====
module PresenceOneOf

def self.included(base)
base.extend(ClassMethods)
end

module ClassMethods
def validates_presence_one_of(*attr_names)
is_valid= true
configuration= { :message => nil, :on => :save }
configuration.update(attr_names.pop.symbolize_keys) if
attr_names.last.is_a?(Hash)
configuration[:message]= “One of the fields " +
attr_names.join(”,") +
" must be non-empty!"

  send(validation_method(configuration[:on])) do |record|
    unless configuration[:if] and not

evaluate_condition(configuration[:if], record)
if attr_names.all? { |attr| record.send(attr).blank? }
is_valid= false
record.errors.add_to_base(configuration[:message])
end
end
end
is_valid
end
end

end

Thanks again,

Many Regards,
Jörg