Validations on parent classes were not taken into accout. I mean, if we have
class Post < ActiveRecord::Base
validates :title, :presence => true
class SpecialPost < Post
semantic_form_for SpecialPost.new do |f|
Then the label for title would not include an asterisk, meaning this field is required (and it should)
This pull request fixes that
include validations on ancestors
Hi, can you please add a test for this. The implementation seems a bit brittle, so I'd like some coverage to make sure we understand what the intent is, and to ensure we don't regress.
I've just realized this wasn't a formtastic bug at all, sorry. I will explain what happened to me just in case it helps someone.
I was using thinking sphinx in the parent class, like that
validates :foo, :bar, :presence => true
class Child < Parent
It happens that thinking_sphinx calls a method called load_models, that will load everything that inherits from ActiveRecord::Base, so that Child will be eventually load (notice that parent has no validators at the moment define_index is called)
Then, Child will copy the validators from Parent (none yet!), and then will finish the loading of Parent, adding the proper validations to :foo and :bar (in Parent but NOT in Child)
So, thank you anyway and sorry for opening an invalid pull request.