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

CarrierWave.root not updating #1743

Closed
randoum opened this issue Sep 20, 2015 · 5 comments
Closed

CarrierWave.root not updating #1743

randoum opened this issue Sep 20, 2015 · 5 comments
Labels

Comments

@randoum
Copy link
Contributor

randoum commented Sep 20, 2015

Found this bug while trying to use CarrierWave.clean_cached_files! from a rake task with a custom CarrierWave.root path. Trimmed it down to the following step by step that can be reproduced on a new project:

Create a new project, and create a config/initializers/carrier_wave.rb with content:

CarrierWave.configure do |config|
  config.root = Rails.root.to_s
end
pp CarrierWave.root

CarrierWave.root  = Rails.root.to_s
pp CarrierWave.root

The output is:

"/path/my_project/public"
"/path/my_project"

Unlike what would be expected, config.root = does not update the value of CarrierWave.root
Thanks in advance for your feedback

@randoum randoum changed the title CarrierWave.root not updated CarrierWave.root not updating Sep 20, 2015
@randoum
Copy link
Contributor Author

randoum commented Oct 16, 2015

@bensie any insights? Thanks

@thomasfedb
Copy link
Contributor

@randoum please try pp CarrierWave::Uploader::Base instead of pp CarrierWave.root.

@randoum
Copy link
Contributor Author

randoum commented Dec 16, 2015

@thomasfedb

CarrierWave::Uploader::Base = Rails.root.to_s
gives
warning: already initialized constant CarrierWave::Uploader::Base

@thomasfedb
Copy link
Contributor

@randoum I never suggested attempting to assign to CarrierWave::Uploader::Base - clearly it's a constant, and quite an important one.

Rather, give this a go:

CarrierWave.configure do |config|
  config.root = Rails.root.to_s
end

pp CarrierWave::Uploader::Base.root

@randoum
Copy link
Contributor Author

randoum commented Dec 26, 2015

Ok. This is strange.

Quick explanation : few months ago I realized that CarrierWave.configure { |c| c.root = Rails.root.to_s } did not suffice and my tmp and upload directories was still present in public (restarted server, stopped spring, deleted those directories, did several tests without success). And the only solution was to add after the configure block the instruction CarrierWave.root = Rails.root.to_s
And that's what motivated me to write this issue.
Anyhow, now removing the additional instruction CarrierWave.root = Rails.root.to_s works as expected (i.e no more tmp or upload in public). I certainly made a mistake at some point.

Well anyhow thanks for your answers.

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

No branches or pull requests

2 participants