aboutsummaryrefslogblamecommitdiffstats
path: root/railties/lib/rails/tasks/railties.rake
blob: 0c1ee0f17add9e1f5852a1891b9a1601618e6216 (plain) (tree)
1
2
3
4
5



                                                                                          
                                                             














                                                                       
namespace :railties do
  desc "Create symlinks to railties public directories in application's public directory."
  task :create_symlinks => :environment do
    paths = Rails.application.config.static_asset_paths.dup
    app_public_path = Rails.application.paths["public"].first

    paths.each do |mount_path, path|
      symlink_path = File.join(app_public_path, mount_path)
      if File.exist?(symlink_path)
        File.symlink?(symlink_path) ? FileUtils.rm(symlink_path) : next
      end

      next unless File.exist?(path)

      File.symlink(path, symlink_path)

      puts "Created symlink #{symlink_path} -> #{path}"
    end
  end
end