Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic association wrong sql #4

Open
pironim opened this issue Feb 11, 2013 · 1 comment
Open

Polymorphic association wrong sql #4

pironim opened this issue Feb 11, 2013 · 1 comment

Comments

@pironim
Copy link

pironim commented Feb 11, 2013

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants