Ok but if i symlink to another directory over the public, wont other
users that arent loged in be able to download these files ?
Yes they will. I didn't realise that you wanted to restrict access.
or should i delete the symlink when logout.. ?
That's messy. Here's a better way to do it:
- Make the directory app/shared/private/ on your server. It should sit beside the existing app/shared/public/. Make a directory files/ inside it and stick your files in there.
- Using Capistrano symlink your app/current/private/ to the shared one. For example, add this to your deploy/config.rb:
# Automatically symlink these directories from current/private to shared/private.
set :app_private_symlinks, %w{ files }
desc "Link up any private directories."
task :symlink_private, :roles => [:app, :web] do
if app_private_symlinks
app_private_symlinks.each { |link| run "ln -nfs #{shared_path}/private/#{link} #{current_path}/private/#{link}" }
end
end
desc "Creates additional symlinks."
task :after_symlink, :roles => [:app, :web] do
symlink_private
end
- In your action, you can do something like:
if @user.logged_in? # or however you determine whether somebody is logged into your app
send_file 'private/files/your_file.txt'
end
It maybe sounds litle bit newbe, im not very skilled yet...
Hey, don't worry about it. Nor am I
Regards,
Andy Stewart