Hi Kennon,
thanks for the very quick answer. I am quite new to rails, so I try to
say it with my own words.
The Picture Model only acts as a kind of "container" for uptaking the
image (attachment), because Paperclip always needs an explicit model
to attach to.
So while attaching the images to the Picture model for each image
(attachment) exactly one Picture object is created, which now can be
used by other models.
By polymorph you mean something like that???
Like this:
class Gallery < ActiveRecord::Base
has_many :gallery_pictures, :as => attachable
has_many :pictures, :through => :gallery_pictures
end
here ist the "as" added
class Product < ActiveRecord::Base
has_many :gallery_pictures, :as => attachable
has_many :pictures, :through => :gallery_pictures
end
this is one hypothtic new model to attach to - the Product model
class GalleryPicture < ActiveRecord::Base
belongs_to :picture
belongs_to :attachable, :polymorphic => true
end
the changed join table (I deleted the rows that mention namele the
gallery and the product model)
class Picture < ActiveRecord::Base
has_many :gallery_pictures
has_many :galleries, :through => :gallery_pictures
has_many :products, :through => :gallery_pictures
has_attachment :image
end
I added the product model here (Or should I delete both lines??)
So, I would like to hear if I understood you correctly. Many Thanks!!!
Andreas