Reputation: 30445
Is there a way to query which attributes on an ActiveRecord model are validated? Say I have a model like this:
class Person < ActiveRecord::Base validates_presence_of :name validates_numericality_of :age end
I would like something like this:
Person.validations => [:name, :age]
Upvotes: 0
Views: 108
Reputation: 115511
This does the trick:
Person.validators.map {|v| v.attributes if v.attributes }.flatten
Upvotes: 3