I've been looking through the ActiveRecord source to find out how :if => proc_or_method_name
works on ActiveRecord validations, but the only instances of :if
in the source are in the comments explaining how the feature should be called.
For example, you can have a line like the following in a model:
validates_presence_of :name, :if => :nameable?
and the validation only gets checked if the nameable?
method returns a truthy value for the given model.
Where is this functionality actually defined, as I can't find this behaviour anywhere in the (Rails2) source?