Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Compatibility problem with carrierwave 0.6.0 #35

Merged
merged 3 commits into from

7 participants

@benzheren

Upgraded to carrierwave 0.6.0, and whenever I start the app, it says undefined method 'grid_fs_database=' for CarrierWave::Uploader::Base:Class)

@yfeldblum

Step 1: Patch carrierwave to have a list of registered drivers and to loop through the registered drivers and add config items that the registered drivers expose.

Step 2: Patch carrierwave-mongoid to register itself as a driver with carrierwave.

@rmm5t
Collaborator

I started a carrierwave-0.6-support branch. Right now, all the existing specs are passing, but I haven't yet combed over everything to make sure it's stable. If anyone has time to test this branch on their projects in development in the meantime, that'd be a big help.

gem "carrierwave-mongoid", :git => "git://github.com/jnicklas/carrierwave-mongoid.git", :branch => "carrierwave-0.6-support"
@gkop

@rmm5t looks good here! It passed my app tests for https://github.com/gkop/bbase and is working fine in production with my legacy dataset as well as new uploads. This is on an upgrade from carrierwave 0.5.4, with the latest stable mongo and mongoid. Thanks!

@jtescher

Works great for me! mongoid-2.4.8, carrierwave-0.6.1

@benzheren

This branch works for me as well with mongoid-2.4.8 and carrierwave-0.6.1

@jhirn

+1

@rmm5t rmm5t merged commit 8f8a918 into from
@rmm5t
Collaborator

Thanks for the help testing, everyone. This is now in the master branch. I want to look into pulling in #34 before a 0.2.0 release, but that release should be soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 8, 2012
  1. @rmm5t
  2. @rmm5t

    Added GridFS config options

    rmm5t authored
    Carrierwave 0.6 no longer initializes these by default anymore
  3. @rmm5t
This page is out of date. Refresh to see the latest.
View
33 README.md
@@ -48,17 +48,36 @@ CarrierWave.configure do |config|
end
```
-## Changes from earlier versions of CarrierWave with Mongoid support built in
+## Version differences
-This version supports ONLY version of mongoid ~> 2.1
+### 0.2.0
-You can use `upload_identifier` to retrieve the original name of the uploaded file.
+carrierwave-mongoid ~> 0.2.0 is only compatible with Rails 3.2 or higher.
+
+### 0.1.x
+
+carrierwave-mongoid ~> 0.1.1 depends on carrierwave ~> 0.5.7. This version of
+carrierwave is only compatible with Rails 3.1 or earlier.
-In the earlier version, the mount_uploader-method for mongoid had been defined in lib/carrierwave/orm/mongoid. This code has been moved to carrierwave/mongoid. If you update from earlier versions, don't forget to adjust your require accordingly in your carrierwave-initializer.
+### Changes from earlier versions of CarrierWave <= 0.5.6
+
+CarrierWave used to have built-in Mongoid support. This gem replaces that
+support and only only supports Mongoid ~> 2.1
+
+You can use `upload_identifier` to retrieve the original name of the uploaded file.
-The default mount column used to be the name of the upload column plus `_filename`. Now it is simply the name of the column. Most of the time, the column was called `upload`, so it would have been mounted to `upload_filename`.
-If you'd like to avoid a database migration, simply use the `:mount_on` option to specify
-the field name explicitly. Therefore, you only have to add a `_filename` to your column name. For example, if your column is called `:upload`:
+In the earlier version, the mount_uploader-method for mongoid had been defined
+in lib/carrierwave/orm/mongoid. This code has been moved to
+carrierwave/mongoid. If you update from earlier versions, don't forget to adjust
+your require accordingly in your carrierwave-initializer.
+
+The default mount column used to be the name of the upload column plus
+`_filename`. Now it is simply the name of the column. Most of the time, the
+column was called `upload`, so it would have been mounted to `upload_filename`.
+If you'd like to avoid a database migration, simply use the `:mount_on` option
+to specify the field name explicitly. Therefore, you only have to add a
+`_filename` to your column name. For example, if your column is called
+`:upload`:
```ruby
class Dokument
View
2  carrierwave-mongoid.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency "carrierwave", ["~> 0.5.6"]
+ s.add_dependency "carrierwave", ["~> 0.6.1"]
s.add_dependency "mongoid", ["~> 2.1"]
s.add_development_dependency "rspec", ["~> 2.6"]
s.add_development_dependency "bson_ext", ["~> 1.3"]
View
19 lib/carrierwave/mongoid.rb
@@ -64,4 +64,23 @@ def find_previous_model_for_#{column}
end # Mongoid
end # CarrierWave
+CarrierWave::Storage.autoload :GridFS, 'carrierwave/storage/grid_fs'
+
+class CarrierWave::Uploader::Base
+ add_config :grid_fs_connection
+ add_config :grid_fs_database
+ add_config :grid_fs_host
+ add_config :grid_fs_port
+ add_config :grid_fs_username
+ add_config :grid_fs_password
+ add_config :grid_fs_access_url
+
+ configure do |config|
+ config.storage_engines[:grid_fs] = "CarrierWave::Storage::GridFS"
+ config.grid_fs_database = "carrierwave"
+ config.grid_fs_host = "localhost"
+ config.grid_fs_port = 27017
+ end
+end
+
Mongoid::Document::ClassMethods.send(:include, CarrierWave::Mongoid)
View
2  lib/carrierwave/mongoid/version.rb
@@ -1,5 +1,5 @@
module Carrierwave
module Mongoid
- VERSION = "0.1.7"
+ VERSION = "0.2.0.pre"
end
end
Something went wrong with that request. Please try again.