I currently have application which allows users to upload an image. Currently. each image belongs to a certain event, or in my case a certain week.
To reduce redundancy and server overload with the same image being uploaded multiple times, I would like to allow the user to upload (1) image and give them the option to assign it to multiple weeks that are load in the database.
Here is the setup now:
Creative Model
class Creative < ActiveRecord::Base
belongs_to :week
mount_uploader :image, CreativeUploader
end
Week Model
class Week < ActiveRecord::Base
has_many :creatives
end
The issue I am having is getting my application to pass multiple [week_id]'s to a single creative.
Should this be converted to a has_and_belongs_to_many relationship with a join table?
NestedForm
<%= creative_form.collection_select(:week_id, @campaign.weeks, :id, :start_at) %>
TIA