Rectangle 27 0

ruby on rails carrierwave multiple file uploads and storing?


class Video < ActiveRecord::Base
  mount_uploader :video, VideoUploader

  before_save :update_video_attributes
  private

  def update_video_attributes
    if video.present? && video_changed?
      self.content_type = video.file.content_type
      self.file_size = video.file.size
    end
  end
end

Add the relevant attributes to your model and introduce a before_save callback.

Can I do this in carrierwave uploader too? do I have to set for each element a special column in table?

Note