Forum: Ruby on Rails Using file_column and switchtower

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.
joevandyk (Guest)
on 2005-12-11 06:38
(Received via mailing list)
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
technoweenie (Guest)
on 2005-12-11 07:03
(Received via mailing list)
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
kyle (Guest)
on 2005-12-11 07:03
(Received via mailing list)
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...
joevandyk (Guest)
on 2005-12-11 07:23
(Received via mailing list)
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?
joevandyk (Guest)
on 2005-12-11 08:18
(Received via mailing list)
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 <controller not set>#<action not set>

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:in `fu_mkdir'
/usr/local/lib/ruby/1.8/fileutils.rb:193:in `mkpath'
/usr/local/lib/ruby/1.8/fileutils.rb:191:in `reverse_each'
/usr/local/lib/ruby/1.8/fileutils.rb:191:in `mkpath'
/usr/local/lib/ruby/1.8/fileutils.rb:177:in `each'
/usr/local/lib/ruby/1.8/fileutils.rb:177:in `mkpath'
#{RAILS_ROOT}/vendor/plugins/file_column/lib/file_column.rb:29:in
`init_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:in
`init_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:in `belongs_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
skanthak (Guest)
on 2005-12-11 16:25
(Received via mailing list)
> 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 <controller not set>#<action not set>
>
> 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
jamis (Guest)
on 2005-12-11 16:33
(Received via mailing list)
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
This topic is locked and can not be replied to.