There are three models:
class Image < ApplicationRecord has_many :lessons, as: :image end class Cover < ApplicationRecord has_many :lessons, as: :image end class Background < ApplicationRecord has_many :lessons, as: :image end Well, the model Lesson, respectively:
class Lesson < ApplicationRecord belongs_to :image, polymorphic: true end As a result, I get an error:
Cannot eagerly load the polymorphic association: image
The error is caused by this code:
Course.all.joins(groups: { lessons: :image }) What could be the problem?