jisaacks / recurse-delete

Rails gem to recursively delete self and all dependent associations without an N+1
25 stars 14 forks source link

Polymorphic association wrong sql #4

Open pironim opened 11 years ago

pironim commented 11 years ago

I have model with polymorphic association:

class View < ActiveRecord::Base belongs_to :viewable, :polymorphic => true end

class Content < ActiveRecord::Base has_many :views, as: :viewable, dependent: :destroy end

class Topic < ActiveRecord::Base has_many :views, as: :viewable, dependent: :destroy end

during the deletion process I got such error. I check through the code - there is no any chech on association type.

Here is error:

ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'views.content_id' in 'where clause': SELECT views.id FROM views WHERE views.content_id IN (253, 255)

jisaacks commented 11 years ago

Thanks for pointing this out, I am really busy right now and have a lot piling up in my queue, but I will look into this when I get a chance. In the meantime, pull requests are always welcome. :)

Thanks.