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)
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. :)
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
FROMviews
WHEREviews
.content_id
IN (253, 255)