You’re not receiving notifications from this thread.
Finding records using Delegated Types
I have a Delegated Types association set up like below and I need to find a particular Collection but the flickr_id is stored in the GalleryItem table. It's failing to return anything. How can I get the following line to work?
collection = Collection.find_by(flickr_id: flickr_collection.id)
class Collection < ActiveRecord::Base include GalleryItemable end
class Album < ActiveRecord::Base include GalleryItemable end
module GalleryItemable extend ActiveSupport::Concern included do has_one :gallery_item, as: :gallery_itemable, touch: true, dependent: :destroy end end
class GalleryItem < ActiveRecord::Base belongs_to :collection, optional: true belongs_to :album, optional: true delegated_type :gallery_itemable, types: %w[ Collection Album ], dependent: :destroy acts_as_list scope: :collection end
I hope someone can help.