Forum: Ruby on Rails RE: Symlinks in Capistrano?

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.
E94ca0face81fe54d0486b397ea3412d?d=identicon&s=25 Campano, David (Guest)
on 2006-04-25 14:21
(Received via mailing list)
This might help, I didn't want to store a rails version in svn or to
make my deployment dependent on the rails site being up.  Therefore, I
checked out rails 1.1.1, and created a directory called rel_1-1-1 under
my home directory.  Then I created this simple task below to create a
symlink whenever it is deploying.  I placed this code into the deploy.rb
file.

desc "Symlink Rails to version 1.1"
task :add_symlink_to_rails, :roles => :web do
  run "ln -s ~/rails/rel_1-1-1/ #{release_path}/vendor/rails"
end

I also modified the long_deploy task to run this custom task right after
the symlink task.

desc "A task demonstrating the use of transactions."
task :long_deploy do
  transaction do
    update_code
    disable_web
    symlink
    add_symlink_to_rails
    migrate
  end

  restart
  enable_web
end

Hope this helps!
678aa0aabf79a4933b7efc6d585dc141?d=identicon&s=25 Matt White (Guest)
on 2006-04-25 16:32
(Received via mailing list)
you can also create an after_deploy task as part of your deploy.rb. it
will
run automatically at the end of the defauly deploy task. (and perhaps
the
others as well? not sure...) This would be similar to what's shown
above,
but perhaps a little simpler if your needs aren't as complex. I do this
to
seperate my static html into shared.

task :after_deploy do
  run "ln -s #{shared_path}/pages #{releases_path}/public/pages"
end

either will work... My needs are simpler, and perhaps yours are as well
;)

Matt
678aa0aabf79a4933b7efc6d585dc141?d=identicon&s=25 Matt White (Guest)
on 2006-04-25 16:35
(Received via mailing list)
whoops. noticed an error. should be:

run "ln -s #{shared_path}/pages #{release_path}/public/pages"
992fe8c19bbbc27f2b562a9f96efc03d?d=identicon&s=25 Jamis Buck (Guest)
on 2006-04-25 17:43
(Received via mailing list)
Note that you can prepend "after_" or "before_" to any task name to
extend the behavior of that task. Thus, if you want to do extra work
at the symlink stage, just create a task called "after_symlink":

   task :after_symlink do
     ...
   end

- Jamis
This topic is locked and can not be replied to.