class Transaction < ActiveRecord::Base
belongs_to :account, :polymorphic => true
end
class Bankaccount < ActiveRecord::Base
has_many :transactions, :as
For those that got this error even when they aren't trying to query conditions on the polymorphic association, it's because includes decided to call eager_load when polymorphic associations are only supported by preload. It's in the documentation here: http://api.rubyonrails.org/v5.1/classes/ActiveRecord/EagerLoadPolymorphicError.html
So you should always use preload for polymorphic associations.