hzamani / acts_as_relation

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

Why does the parent class need it's own id? #1

Closed dschmura closed 13 years ago

dschmura commented 13 years ago

Hi Hassan,

I am wondering why the parent class needs to have an explicit parent_class_id object? Isn't this something that could be automatically derived from the id?

I am fairly new to ROR (and trying to bite off a big bite on the first go), so I apologize if the answer is self-evident.

Thanks,

Dave

hzamani commented 13 years ago

acts_as add a has_one :parent to child models. usually for has_one association parent class needs a child_id, but here we use this for multiple models and so I decided to use parent_id because all children act as parent!

dschmura commented 13 years ago

Thanks. As I am reading and learning more about polywhozits, the answer became clear. Sorry for the trouble. I would love to see more documentation on using acts_as_relation within a rails site (doing the crud views for example). I am still very much on training wheels, and I understand that it is not your job to provide a learning scaffold for me, but it would be helpful. If not, when I get my legs under me I will write something up.

Thanks again,

Dave