Using file_column and switchtower


#1

I haven’t actually tried it yet, but I think switchtower conflicts
somewhat with file_column.

file_column puts uploads in the public directory. But when you do a
‘rake deploy’ with switchtower, then the files that were in the public
directory aren’t used by the newly released svn export of your site
(because a new public directory is created).

What’s the easiest way around this issue?

Thanks,
Joe


#2

On 12/10/05, Joe Van D. removed_email_address@domain.invalid wrote:

Thanks,
Joe

Create the upload directory in shared and then an after_symlink
callback in switchtower that links it into public/uploads.


rick
http://techno-weenie.net


#3

On 12/10/05, Rick O. removed_email_address@domain.invalid wrote:

Create the upload directory in shared and then an after_symlink
callback in switchtower that links it into public/uploads.

So, if files are normally stored in public/training_event, I’d create
a directory shared/uploads/training_event and symlink that to
public/training_event?


#4

On 12/10/05, Rick O. removed_email_address@domain.invalid wrote:

Create the upload directory in shared and then an after_symlink
callback in switchtower that links it into public/uploads.

I have current/public/training_event symlinked to
shared/uploads/training_event.

Here’s the error I get when I try to load anything:

Errno::EEXIST in #

File exists -
/home/joevd/cisv/current/public/…/config/…/public/training_event
RAILS_ROOT: /home/joevd/cisv/current/public/…/config/…

Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/1.8/fileutils.rb:212:in mkdir' /usr/local/lib/ruby/1.8/fileutils.rb:212:infu_mkdir’
/usr/local/lib/ruby/1.8/fileutils.rb:193:in mkpath' /usr/local/lib/ruby/1.8/fileutils.rb:191:inreverse_each’
/usr/local/lib/ruby/1.8/fileutils.rb:191:in mkpath' /usr/local/lib/ruby/1.8/fileutils.rb:177:ineach’
/usr/local/lib/ruby/1.8/fileutils.rb:177:in mkpath' #{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column.rb:29:ininit_options’
#{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column.rb:28:in each' #{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column.rb:28:ininit_options’
#{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column.rb:594:in
file_column' #{RAILS_ROOT}/app/models/training_event.rb:11 (eval):5:inbelongs_to’
#{RAILS_ROOT}/app/models/registration.rb:2
(eval):5:in `has_many’
#{RAILS_ROOT}/app/models/user.rb:13
#{RAILS_ROOT}/app/controllers/application.rb:9
This error occured while loading the following files:
/home/joevd/cisv/current/public/…/config/…/app/controllers/application.rb
=> model user.rb
user
registration
training_event


#5

I have current/public/training_event symlinked to shared/uploads/training_event.

Here’s the error I get when I try to load anything:

Errno::EEXIST in #

File exists - /home/joevd/cisv/current/public/…/config/…/public/training_event
RAILS_ROOT: /home/joevd/cisv/current/public/…/config/…

hmm, that’s strange, because I’m using FileUtils.mkpath, which creates
all the directories if they aren’t there already but shouldn’t
complain if it already exists. I’m wondering if it has troubles with
the symlinks. Can anybody shed some light on this?

Sebastian


#6

On Dec 11, 2005, at 7:23 AM, Sebastian K. wrote:

callback in switchtower that links it into public/uploads.
RAILS_ROOT: /home/joevd/cisv/current/public/…/config/…

hmm, that’s strange, because I’m using FileUtils.mkpath, which creates
all the directories if they aren’t there already but shouldn’t
complain if it already exists. I’m wondering if it has troubles with
the symlinks. Can anybody shed some light on this?

Actually, FileUtils.mkdir_p will act as you describe. FileUtils.mkdir
will choke if the path already exists.

  • Jamis

#7

I store my file_column database outside of the app path. I also
include the rails environment in the path. You don’t need to do this,
but I consider it a best practice.

To include the rails environment in your file_column path, set the
following file_column options:
:root_path => File.join(RAILS_ROOT, “public”, RAILS_ENV),
:web_root => RAILS_ENV + “/”

If you want to do this globally, you can patch the source (look for
“DEFAULT_OPTIONS”), or you can pass it like: file_column :field,
options.

Here’s the gist of my folder structure:

/u/apps/myapp/
/u/file_column_db/myapp/production/

Then, I modifed my deploy.rb file to include the following in the
restart task (another task may be more appropriate, but this works)

sudo “ln -s /u/file_column_db/myapp/production
/u/apps/myapp/current/public/production”

Of course, you need to set the appropriate permissions on everything…