Christian Fazzini
Christian Fazzini

Reputation: 19723

Where should uploaded files get stored in Rails 3.1?

When user uploads files. In Rails 3.0+, these would go into public/uploads. In 3.1, should uploaded files go to app/assets/uploads? Or still in public/uploads?

It's not really an issue in our environment, since we are using S3. Just trying to understand Rails 3.1's new directory structure.

What are your thoughts?

Upvotes: 5

Views: 1598

Answers (4)

DGM
DGM

Reputation: 26979

Putting uploaded files in the filesystem only works if you have one file server or a network mapped storage... I usually just put the files in the database itself.

But as vrsmn said, don't use assets for this, assets pipeline is for streamlining the css/js/application images.

Upvotes: 0

Tilo
Tilo

Reputation: 33732

adding on to apneadiving's answer:

if you use Carrierwave , the temporary files are in your system's /tmp directory and the uploaded files are in a subdirectory underneath $RAILS_ROOT/public , e.g. $RAILS_ROOT/public/uploads/YOUR-MODEL/...

In Rails 3.1 the 'assets' directory is meant for the JavaScript and CSS files so that sprockets can pick them up there and so that they are not accessible directly via the "public" directory...

  see: assets/javascripts/application.js and assets/stylesheets/application.css  files
  see: http://railscasts.com/episodes/265-rails-3-1-overview

The app/assets directory is for CoffeeScript files (also not publicly accessible, so not a place to put uploads)

Upvotes: 0

apneadiving
apneadiving

Reputation: 115521

Well, the answer is simple: your users will only have access to your /public directory.

There are just some tricks to get css and js but you'll have to stick with /public for the other stuff.

Generally, I put all stuff in /public/assets

Upvotes: 3

x0rist
x0rist

Reputation: 625

the public directory, capistrano recommends public/system/

don't get confused by the app/assets directory, it's usually for css/js/coffeescript files, think this is the biggest change from 3.0 to 3.1

Upvotes: 7

Related Questions