I have model named Slider
class Slider < ActiveRecord::Base
end
and HomeBannerSlider
which has single table inheritance relation with slider
class HomeBannerSlider < Slider
has_many :images, as: :imageable
accepts_nested_attributes_for :images, reject_if: :all_blank, allow_destroy: true
end
and Image
model as given
class Image < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
has_attached_file :image
end
My problem is whenever I save HomeBannerSlider
with following command
@admin_home_banner_slider = HomeBannerSlider.new(admin_home_banner_slider_params)
@admin_home_banner_slider.save
It saves the imageable_type
in Image
model as Slider
@admin_home_banner_slider.images
<Image:0x007f5e6ef7af20
id: nil,
imageable_id: nil,
imageable_type: "Slider",
title: "2",
description: "2",
link_button: nil,
link_button_title: nil,
owner: nil,
publish: nil,
priority: nil,
created_at: nil,
updated_at: nil,
image_file_name: nil,
image_content_type: nil,
image_file_size: nil,
image_updated_at: nil>]
but i want it to store imageable_type
as HomeBannerSlider