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"
    end

    -n–no-dereference
             treat destination that is a symlink to a directory as if it were a normal file
    -f–force
           remove existing destination files
    -s–symbolic
           make symbolic links instead of hard links

Advertisements

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s