H
H
HaruAtari2014-01-11 17:27:23
Ruby on Rails
HaruAtari, 2014-01-11 17:27:23

Ruby on Rails: where to store media files?

Good evening.
I am transferring a small project in php (yii) to ror. At the same time, I am absolutely not familiar with the rails, I study along the way.
In general, the development is going quite briskly, apparently the knowledge of several php frameworks affects. But some points are not clear. One of them: how to store large media files? By media files, I mean static that is not directly involved in the formation of the page. This is a repository of files available for users to download.
When working with php, the application directory had two subdirectories: www, which contained the application's executable files. And next to it is the second - storage, in which all the statics lay. It was referenced by a separate subdomain and the work was done through it.
Technically, it was not difficult to organize it. An alias was declared in the Yii configs and further work was carried out with it.
And how to organize the same logic on rails? The first thought was to place the repository in the public directory, but in this case the files will still be in the directory with executable files. I would ask Google, but, to be honest, I don’t know what to ask.
Can you tell me how to do this in a rail application?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Sidorov, 2014-01-12
@morr

this is done by creating a directory on the server, which is separate from the application and is symlinked to the public directory with each deployment.
More details:
if files are uploaded by users, then they can be uploaded by paperclip or carrierwave gems,
both gems will upload files somewhere, for example, to the public/screenshots directory
you will need to shove this directory into .gitignore so that it does not get into the repository of the
application you deploy, I hope, through capistrano
on the production server in the directory where the deployment will go, in the shared directory you will need to create your directory
and set it in the capistrano config, so that Capistrano made a symlink from #{shared_path}/screenshots to #{release_path}/screenshots
example of a config piece for capistrano 3:take.ms/NwlI9
you only need to specify the names of files and directories, and then Capistrano will do everything himself

A
Arkady Butermanov, 2014-01-12
@Arkadey

Store on Amazon S3.

F
flskif, 2014-01-12
@flskif

When uploaded by users, you can save files to any folder on the server that is convenient for you (the links above were given on how to set up a paperclip so that it saves where you need). Since it's static, you don't need rails at all to render it. Just set up something that will serve files (nginx for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question