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


One thought on “Creating a symlink/symbolic link in Rails

  1. […] at the suggestion from here […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s