EngineYard : Segregating the code & assets - ruby-on-rails

Am using EngineYard to host my Rails 3.2 app. This application allows users to post images/assets. I save them in the public directory (using Paperclip Gem). Now, my problem is that - with a new deployment, I am having to manually copy over the assets to the CURRENT version.
Though, I could use AmazonS3, I still want to figure out if there is a way in EngineYard which lets me save/serve the assets from a different directory than the code, say /data/assets.
Please, let me know if you see any other alternate implementations too.

Typically your structure would look like
/data
myapp/
shared/
images
releases/
20120613000000
20120601000000
...
current (symlink to one of the releases)
When you deploy, you symlink public/images to shared/images and so your images always get stored in a non release dependant location.
I would encourage you to use something like s3: you'll make things a lot easier for when you want to host the app on multiple instances.

Related

Which directory should I save generated image in rails as a best practice?

I created a image with rails apps by using rmagick and save the images to public/images.
But it looks like capistrano default rails job reset the folder each deploy.
Should I configure capistrano that public/images must not deleted.
Or first of all that was wrong idea to generate images to public/images?
Generally, the standard is to keep the publicly accessible content in the public directory. And for storing images we can use both public directory (provided we want them to be publicly accessible) or in some cloud based storage like Amazon s3. That is perfectly based on the requirement.
And finally, as you are keeping some dynamically generated data or may be user uploaded data in public directory, you should configure capistrano not to delete/modify those data.

Carrierwave to different upload folder | Routes not correct

I need to configure my carrierwave gem in rails to use a different upload folder beyond the whole rails scope.
I have a VPS and using RVM, ruby, rails. I'm deploying with capistrano, but every time a deploy takes place, the upload folder changes to the new deployed version and not taking all the older images with it.
I want to have a folder that is static and not going to be changed every deployment. But i cant seem to get the solid settings, the cache and store directories are being changed. Also when i'm using Rails.root (this gets me the current capistrano deployment folder) need to get 1 or 2 maps above this folder (way beyond the rails.root)
How could i change this settings so that this is going to work?
Thank you for your time
Update
Changed to full url : /home/deploy/rails_apps/site/uploads/ and its being uploaded. Only when i want to display the picture, this gives me a X mark. If i want to open the image by the firebug inspector, it gives me the error:
No route matches [GET] "/home/deploy/rails_apps/site/uploads/product/image/5/thumb_test.png"
How must i make a route that's beyond this application?
Are you using shared configs with symlinks with Capistrano on your VPS?
If so, you can make there a config for carrier wave picture folder which won't get overwritten. Than you can also use different setting on dev- and deployment machine.
You can take a look at this screencast: Capistrano Tasks from Ryan Bates
Hope it helps.

Rails - Change Image Directory?

I've developed a simple app to display images in a series of subdirectories based on querystring input. (I more or less built my own Rails version of 360Works SuperContainer, for FileMaker.) I have copied a few test directories into public/images and everything seems to be working just great, but this app needs to operate over upwards of 60gb of images, and putting them all into the public/images folder isn't going to really be feasible.
Other than hard-coding the path into my model, how can I set a configuration option to specify a different default directory for the images folder?
I think you can change the asset_host field :
http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#M001688

Where do you place documents belonging to a Rails app project?

For every project it's like having two parts: the Rails application and then all documents and pictures related to it.
I wonder how you organize them both.
Do you put everything under the same project root folder and apply Git on that folder or don't you protect your documents with Git at all?
Then, what if the docs are too sensitive or only for owners of that project. Then I probably should't have it under the same folder right?
How have you structured both your Rails code and belonging business documents?
Share your solutions!
If you're deploying with capistrano, as a lot of Rails apps are, the standard solution seems to be to keep these sorts of assets within the shared folder, and then get cap to symlink them into the application at the point of deploy.

Directory to store cached files in Rails?

I am generating some large files in my Rails application. Fortunately, they only need to be generated once. I would like to save these files to disk so that I don't have to generate them again.
Which directory in my Rails application is the most appropriate place to put application generated files?
Thanks!
If security of the files is not an issue you can put them in a subdirectory of public (for example, public/assets) which in your deploy script is symlinked to a directory in shared/public so that when you redeploy the files are retained.
If security is an issue, the solution is similar, though you would not want the directory to be web accessible. Instead you would use a controller to control access and serve up the files with send_file.

Resources