Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from skyeagle/master
Consistency with mongoid ~> 2.1 and fully extracted from carrierwave(0.5.6)
- Loading branch information
Showing
13 changed files
with
510 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ pkg/* | |
.bundle | ||
spec/public | ||
.rvmrc | ||
Gemfile.lock | ||
Gemfile.lock | ||
log/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# CarrierWave for Mongoid | ||
|
||
This gem adds support for Mongoid and MongoDB's GridFS to CarrierWave, see the | ||
CarrierWave documentation for more detailed usage instructions. | ||
|
||
### This version supports ONLY version of mongoid ~> 2.1 | ||
Keep in mind that if you came up from previous versions you should make a few steps to go with it: | ||
|
||
* change(rename in db) field name from `avatar_name` to `avatar`(appropriate to your uploader name) | ||
* fix you code where you need to operate with uploaded file's filename from `avatar` to `avatar_identifier` | ||
|
||
Install it like this: | ||
|
||
gem install carrierwave-mongoid | ||
|
||
Use it like this: | ||
|
||
```ruby | ||
require 'carrierwave/mongoid' | ||
``` | ||
|
||
Make sure to disable auto_validation on the mounted column. | ||
|
||
Using bundler: | ||
|
||
```ruby | ||
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' | ||
``` | ||
|
||
This used to be part of CarrierWave but has been extracted. | ||
|
||
## Using MongoDB's GridFS store | ||
|
||
You'll need to configure the database and host to use: | ||
|
||
```ruby | ||
CarrierWave.configure do |config| | ||
config.grid_fs_database = 'my_mongo_database' | ||
config.grid_fs_host = 'mongo.example.com' | ||
end | ||
``` | ||
|
||
The defaults are `carrierwave` and `localhost`. | ||
|
||
And then in your uploader, set the storage to `:grid_fs`: | ||
|
||
```ruby | ||
class AvatarUploader < CarrierWave::Uploader::Base | ||
storage :grid_fs | ||
end | ||
``` | ||
|
||
Since GridFS doesn't make the files available via HTTP, you'll need to stream | ||
them yourself. In Rails for example, you could use the `send_data` method. You | ||
can tell CarrierWave the URL you will serve your images from, allowing it to | ||
generate the correct URL, by setting eg: | ||
|
||
```ruby | ||
CarrierWave.configure do |config| | ||
config.grid_fs_access_url = "/image/show" | ||
end | ||
``` | ||
|
||
## Known issues/ limitations | ||
|
||
If using Mongoid, note that embedded documents files aren't saved when parent documents are saved. | ||
You must explicitly call save on embedded documents in order to save their attached files. | ||
You can read more about this [here](https://github.com/jnicklas/carrierwave/issues#issue/81) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bork bork bork Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
Oops, something went wrong.