From what I can tell, validates_uniqueness_of calls exists?(), which isn't going to work in your current code, I believe. If you, say, try to do SubThing.exists?(:name => 'foo') ... it's going to generate SQL query with "WHERE sub_things.name = 'foo'" which will then throw a StatementInvalid error because there's no 'name' column on the sub_things table.
I believe it needs to somehow traverse back up in the case of exists?() and see if the supplied attribs work for the parent object. Unfortunately, I've tried to hack that in and couldn't get something that worked reliably. Not sure why...
From what I can tell, validates_uniqueness_of calls exists?(), which isn't going to work in your current code, I believe. If you, say, try to do SubThing.exists?(:name => 'foo') ... it's going to generate SQL query with "WHERE sub_things.name = 'foo'" which will then throw a StatementInvalid error because there's no 'name' column on the sub_things table.
I believe it needs to somehow traverse back up in the case of exists?() and see if the supplied attribs work for the parent object. Unfortunately, I've tried to hack that in and couldn't get something that worked reliably. Not sure why...