carrierwave
https://github.com/carrierwaveuploader/carrierwave
Ruby
Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
CarrierWave::Uploader::Mountable#initialize
If a model is given as the first parameter, it will be stored in the
uploader, and available through +#model+. Likewise, mounted_as stores
the name of the column where this instance of the uploader is mounted.
These values can then be used inside your uploader.
If you do not wish to mount your uploaders with the ORM extensions in
-more then you can override this method inside your uploader. Just be
sure to call +super+
=== Parameters
[model (Object)] Any kind of model object
[mounted_as (Symbol)] The name of the column where this uploader is mounted
=== Examples
class MyUploader < CarrierWave::Uploader::Base
def store_dir
File.join('public', 'files', mounted_as, model.permalink)
end
endEdit
git clone [email protected]:carrierwaveuploader/carrierwave.git
cd carrierwave
open lib/carrierwave/uploader/mountable.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-CarrierWave--Uploader--Mountable-initialize-for-pr
# Commit to gitgit add lib/carrierwave/uploader/mountable.rbgit commit -m "better docs for CarrierWave::Uploader::Mountable#initialize"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-CarrierWave--Uploader--Mountable-initialize-for-pr
hub pull-request
# Celebrate!