Forum: Ruby on Rails Saving images in shared directory w/ Capistrano/SVN?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-01 06:03
Hi all,

I'm using Capistrano and SVN to version control and deploy, but I'm not
sure what to do about my images directory.  I use file_column and
RMagick to save images to the disk under a model called "Image", and
they're saved in public/image/... etc.

Each time I deploy a new version, my image folder doesn't exist anymore.
I don't want to version control map my local image folder to the
server's image folder, so what should I do?

Is it possible to save my images in a shared folder and let Capistrano
know about that?

Thanks,
Jeff
54077fb03c95861af85880218cf7aef2?d=identicon&s=25 Gokhan Arli (sylow)
on 2006-04-01 06:04
Jeff Coleman wrote:
> Hi all,
>
> I'm using Capistrano and SVN to version control and deploy, but I'm not
> sure what to do about my images directory.  I use file_column and
> RMagick to save images to the disk under a model called "Image", and
> they're saved in public/image/... etc.
>
> Each time I deploy a new version, my image folder doesn't exist anymore.
> I don't want to version control map my local image folder to the
> server's image folder, so what should I do?
>
> Is it possible to save my images in a shared folder and let Capistrano
> know about that?
>
> Thanks,
> Jeff

Yep, use shared folder and write recipie in cap to create sym links from
public/image
3dd4b52a0946bd698b1d1635a46ea3a3?d=identicon&s=25 François Beausoleil (fbeausoleil)
on 2006-04-01 06:37
(Received via mailing list)
2006/3/31, Gokhan Arli <gokhan@sylow.net>:
> Jeff Coleman wrote:
> > Is it possible to save my images in a shared folder and let Capistrano
> > know about that?
>
> Yep, use shared folder and write recipie in cap to create sym links from
> public/image

Make a symlink on the production system and svn add the symlink.
Subversion will notice it is a symlink and will recreate the symlink
on subsequent checkouts.

You need SVN 1.1 or better for this to work.  See
http://svnbook.red-bean.com/nightly/en/svn.advance...
for details.

Bye !
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-01 06:40
François Beausoleil wrote:
> 2006/3/31, Gokhan Arli <gokhan@sylow.net>:
>> Jeff Coleman wrote:
>> > Is it possible to save my images in a shared folder and let Capistrano
>> > know about that?
>>
>> Yep, use shared folder and write recipie in cap to create sym links from
>> public/image
>
> Make a symlink on the production system and svn add the symlink.
> Subversion will notice it is a symlink and will recreate the symlink
> on subsequent checkouts.
>
> You need SVN 1.1 or better for this to work.  See
> 
http://svnbook.red-bean.com/nightly/en/svn.advance...
> for details.
>
> Bye !

Wow, that is nice.  I went ahead and made a cap recipe to recreate the
symlink, but that's pretty much seamless.  Thanks!

Jeff
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-04-01 23:22
(Received via mailing list)
I just blogged this:
http://kylemaxwell.com/articles/2006/04/01/using-f...

---------

I assume that you already have basic familiarity iwth Ruby, Rails, the
Rails plugin system, Capistrano, and FileColumn (or file_column), but
not neccessarily the internals of the above programs.

Let's get them all working together.

First, for convienience, you should choose the name of a folder in
your site for the file_column content to reside. I usually set this to
RAILS_ENV, so that I can run with multiple environments on one rails
app. Your file_column content is tied to a specific database, and if
multiple environments use the same folder, then you have the potential
to overwrite data.

Ok, so you've chosen your folder name. I'll assume you've stuck to my
convention of www.yoursite.com/RAILS_ENV/, but you can choose a
prettier name if you'd like. We're going to make file_column
understand this preference in one of two ways:

1. Call file_column with options:

file_column :some_image,
  :root_path => File.join(RAILS_ROOT, "public", RAILS_ENV),
  :web_root => RAILS_ENV + "/"

The problem with this is that its not very DRY. To make it DRY, you
should:

2. Modify the DEFAULT_OPTIONS hash directly, in
vendor/plugins/file_column/lib/file_column.rb, around line 500 or so.

Now you've got to make Capistrano symlink this folder into another
folder in your shared directory. To do this, add the following to your
deploy.rb recipe. Then run `cap setup`

task :after_setup
  run "mkdir #{shared_path}/production"
end

task :after_symlink do
  run "ln -nfs #{shared_path}/production
#{release_path}/public/production"
end

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
This topic is locked and can not be replied to.