NilsHaldenwang
NilsHaldenwang

Reputation: 3667

How to remove folder from Rails autoload?

in my application people can upload files with paperclip. One user stored a ruby script, which is placed in a folder like app/assets/assignment_attachments.

Sadly, when my application tries to start it executes this ruby script which doesn't work, because it includes stuff my application doesn't know.

The question is: How can I stop Rails from autoloading this files? I tried the following in my config/application.rb without success:

 config.eager_load_paths -= [Dir["#{config.root}/app/assets/assignment_attachments/**"]]
 config.autoload_paths -= [Dir["#{config.root}/app/assets/assignment_attachments/**"]]

How do I exclude those files from beeing executed?

Kind regards,

Nils

Upvotes: 2

Views: 1251

Answers (1)

Lasse Bunk
Lasse Bunk

Reputation: 1858

I don't think uploaded files should be stored in your app folder as this is used – as the name says – for your app code.

The default is to use public/system that can be symlinked to e.g. /www/myapp/shared/system (for example if you use Capistrano for deployment) to be shared between deploys.

See https://github.com/thoughtbot/paperclip#understanding-storage for help.

Upvotes: 2

Related Questions