Reading AR validations at runtime

Does anyone, by chance, know how to obtain a list of all the defined
activerecord validations at runtime?

In other words, I’d like to query a model for all the fields that are
unique, or required.

I found this: read_inheritable_attribute(:validate), but it seems to be
deprecated in later versions of rails. Thanks so much for any insight.

On Wednesday 15 July 2009, Will Grundler wrote:

Does anyone, by chance, know how to obtain a list of all the defined
activerecord validations at runtime?

http://rubyforge.org/projects/valirefl/
http://github.com/mschuerig/validation_reflection/tree/master

HTH,
Michael


Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/

Thanks Michael! That’s a big help.

Michael S. wrote:

On Wednesday 15 July 2009, Will Grundler wrote:

Does anyone, by chance, know how to obtain a list of all the defined
activerecord validations at runtime?

http://rubyforge.org/projects/valirefl/
http://github.com/mschuerig/validation_reflection/tree/master

HTH,
Michael


Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs