TODO: Write a gem description
Add this line to your application's Gemfile:
gem 'carrierwave-activerecord'
And then execute:
$ bundle
Or install it yourself as:
$ gem install carrierwave-activerecord
TODO: Write usage instructions here
To use the activerecord store add the following line to your uploader:
storage :active_record
The gem currently assumes that there is a table in the database with the name
carrier_wave_filesto store the images in. This table must have the
following columns:
- original_filename: string
- content_type: string
- extension: string
- filname: string
- size: integer
- data: binary
- storage_path: string
The gem needs a database connection. Inside a rails app the default connection can be used. For the usage in a non-rails environment ensure that the datatabase connection is ready before starting to store files with an uploader.
The gem assumes that there is a service that is responsible to handle web requests for the files in the db. The Service should be able to handle a HTTP request like this:
GET /files/images/sample.png HTTP/1.1
The path of the files is composed of two parts:
- the downloader_path_prefix for routing issues
- and the storage_path of the file
The downloader_path_prefix can be configured with the downloader_path_prefix option available to CarrierWave::Uploader::Base
TODO Example
It defaults to "/files".
The storage path is a property of each file in the db. It is defined by calling the identifier method on the uploader.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
If you like the work we've done so far and you encounter some issues please invest some of your time to enhance the code and create a pull request.