I have the following STI models, they have a polymorphic association, whose query is being wrongly constructed
class Product < ApplicationRecord
has_many :images, as: :imageable
end
class OneProduct < Product
end
class Image < ApplicationRecord
belongs_to :imageable
end
In a rails console, when I do
> OneProduct.last.icon_images
The query being fired is
SELECT * FROM images WHERE imageable_id = id AND imageable_type = 'Product'
I was expecting:
SELECT * from images WHERE imageable_id = id AND imageable_type = 'OneProduct'
Am I expecting something wrong?
Side Info: database is postgres.