views:

89

answers:

0

Hi

I cant figure out how to validate that carrierwave has uploaded a document to my mongoid object.

i have a Document Class

class Content::Document < Content

  mount_uploader :attachment, DocumentUploader   

  field :attachable_id
  field :attachable_type
end

and an uploader:

require 'carrierwave/orm/mongoid'
class DocumentUploader < CarrierWave::Uploader::Base

  storage = :filesystem
  include CarrierWave::RMagick

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end          

  def extension_white_list
    %w(doc docx xls xlsx ppt pptx pdf )
  end

i would like to validate that the upload exists and that it matches the white list else through a standard validation error

this is on Rails 2.3.8