Creating a symlink/symbolic link in Rails

  • symbolic links: Refer to a symbolic path indicating the abstract location of another file

    Syntax: ln -s {target-filename} {symbolic-filename}

    For example create symlink for /home/work/index.rb as/home/Aakash/index.rb, enter the following command:

    ln -s /home/work/index.rb /home/Aakash/index.rb
    On doing ls -l , it shows output as

    lrwxrwxrwx 1 Aakash  Aakash    16 2013-09-20 10:47 index.rb -> /home/Aakash/index.rb
    To simply delete the link
    Use rm {link-name}
    i.e  rm index.rb
  • Rails way of creating a Symlink while using Capistrano recipes is as :
    after “deploy:update_code” do # Run bundle install
    run "ln -nfs #{shared_path}/public/techease #{release_path}/public/techease"

             treat destination that is a symlink to a directory as if it were a normal file
           remove existing destination files
           make symbolic links instead of hard links