Rails STI validation inheritance
Posted
by
KARASZI István
on Stack Overflow
See other posts from Stack Overflow
or by KARASZI István
Published on 2011-01-11T16:50:33Z
Indexed on
2011/01/11
16:53 UTC
Read the original article
Hit count: 229
Dear Rails users!
I have STI models in my Rails application. The ancestor model has validations with the validates_...
methods which are working fine.
But I have custom validations as well, and I would like to add more different custom validations in the descendants. These custom validations would depend on the class.
If I write
class DescendantA < Ancestor
protected
def validate
# ...
end
end
It simply overwrites the original validations. Is there a convention to do this in Rails?
© Stack Overflow or respective owner