hzamani / acts_as_relation

Multi table Inheritance for rails
http://hzamani.github.com/acts_as_relation/
MIT License
180 stars 58 forks source link

validates_uniqueness_of() and exists?() don't work #3

Closed mepatterson closed 12 years ago

mepatterson commented 13 years ago

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...

hzamani commented 13 years ago

can you paste your code?