Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: allow option "overwrite: true" for mount_uploader #200

Open
bblack opened this issue Dec 10, 2020 · 1 comment
Open

Feature request: allow option "overwrite: true" for mount_uploader #200

bblack opened this issue Dec 10, 2020 · 1 comment

Comments

@bblack
Copy link

bblack commented Dec 10, 2020

We're using redactor-rails (which is years out of date at this point). That lib provides some facility for a fancy text editor, to which a user can supply attachments like inline pictures. The lib provides an out-of-the-box base class for models backed by mongoid (an ORM for MongoDB), which will upload those attachments using carrierwave, and store the resulting URL on that model record.

That base class, on inclusion into the application's actual model classes, defines several fields:

https://github.com/SammyLin/redactor-rails/blob/3dc460d9f2b84625219349a811cca7c33549fad0/lib/redactor-rails/orm/mongoid.rb#L19

An effect of this is that, if we then call carrierwave-mongoid's mount_uploader, one of two things will happen:

  1. If that call includes :mount_on => :data_file_name, which is the name of the field that redactor-rails already defined, then a warning is produced.
  2. Otherwise, the field that redactor-rails defined ends up being useless.

Certainly carrierwave-mongoid cannot (and should not) do anything about effect 2. And although carrierwave-mongoid should not (per se) do anything to prevent effect 1, it would be nice to offer the caller the choice to suppress it. For example:

mount_uploader :data, RedactorRailsPictureUploader, 
  mount_on: :data_file_name,
  overwrite: true

Then overwrite could be passed along to mongoid's field.

@bblack
Copy link
Author

bblack commented Dec 10, 2020

That warning from mongoid, by the way, is e.g.

Overwriting existing field data_file_name in class RedactorRails::Picture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant