Sha256: bdb67090513f4845513ad47e050572459950e3d10a098c610ca6f30824f62a8b

Contents?: true

Size: 476 Bytes

Versions: 2

Compression:

Stored size: 476 Bytes

Contents

class FileUploader < CarrierWave::Uploader::Base
  storage :file
    def timestamp
      time=if model
        model.created_at || Time.now
      else
        Time.now
      end
      time.strftime("%Y%m")
    end

    # With slash in first place it will be absolute url, otherwise relative to Rails.root+"/public"
    def store_dir
      if model
        "upload/#{model.class.to_s.underscore}/#{timestamp}/#{model.id}"
      else
        "upload/misc"
      end
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolita-file-upload-0.1.3 app/uploaders/file_uploader.rb
lolita-file-upload-0.1.2 app/uploaders/file_uploader.rb