forked from mdespuits/capistrano-recipes
-
Notifications
You must be signed in to change notification settings - Fork 3
/
paperclip.rb
48 lines (35 loc) · 1.1 KB
/
paperclip.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# @author Dmytro Kovalov [email protected]
#
# Oct 2013, Tokyo
#
# Capistrano config for Paperclip gem. Include this recipe
# in your deploy.rb
#
set_default :paperclip_dir, "public/uploads"
namespace :paperclip do
desc <<-DESC
Create directory for the Paperclip uploads.
For your Paperclip configuration add path to the directory in
`application.rb` as:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
config.paperclip_defaults = {
:path => ":rails_root/public/uploads/:class/:attachment/:id/:style/:filename"
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Source: #{path_to __FILE__}
DESC
desc <<-DESC
Symlink paperclip directory to cuurent release.
Source: #{path_to __FILE__}
DESC
task :setup do
try_sudo "mkdir -p #{shared_path}/#{paperclip_dir}"
sudo "chown -R #{user} #{shared_path}/#{paperclip_dir}"
end
task :symlink do
run "rm -rf #{release_path}/#{paperclip_dir}"
run "ln -nfs #{shared_path}/#{paperclip_dir} #{release_path}/#{File.dirname paperclip_dir}"
end
end
after "deploy:finalize_update", "paperclip:symlink"
after "deploy:setup", "paperclip:setup"