hzamani / acts_as_relation

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

Dependent Destroy does not work ? #75

Closed zuernBernhard closed 10 years ago

zuernBernhard commented 10 years ago

Reffering to the example I assume the following situation:

There is a Product Model as Super Class and A Pen Model as Subclass.

There are 2 Instances: Pen with id = 3 and Product with id = 2 and product_id = 3 (The Pen)

Now I want to Delete them from the Database with an URL like:

product/2/delete

In the corresponding controller-method I do:

Product.destroy(2)

Now the Product is deleted but the Pen still exists in the Database.

I can get around that with:

product = Product.find(params[:id]) specific_product_model = product.as_product_type.classify.constantize specific_product_model.destroy(product.product_id) Product.destroy(product.id)

Is that right ? Do I really have to do it that way ?

hzamani commented 10 years ago

Fixed in master branch