-
Add images to your projects & users model using the Paperclip Gem
-
Implement Paperclip by one of three methods: Directly on Model, Through an associated model (Gallery Images), or through polymorphic associations across multiple models.
To set up the association entirely through a generator & set up an index in the migration, do:
rails generate model picture caption description:text pictureable:references
In your migration, make sure you add polymorphic: true
class CreatePictures < ActiveRecord::Migration
def change
create_table :pictures do |t|
t.string :caption
t.text :description
t.references :pictureable, polymorphic: true
t.timestamps
end
add_index :pictures, :pictureable_id
end
end