Getting started with Rake - how do I copy a directory of assets to RAILS_ROOT + "/public"

I am just getting started with Rake. I am trying to create a rake task
from within a rails plugin to copy some asset files (inside /assets in
my plugin folder) to my rails application /public folder.
How can I achieve this?

I am not sure whether to use FileUtils or File. Where AM I in rake
terms. No matter what I do it keeps saying it can’t find the file. Do
I need to use File.join or is there a better rake way? Any resources
out there on how to use rake for file oriented tasks like this? Should
I use a generator instead?


require ‘ftools’ #file tools

desc “Installs famfam icons and stylesheets in application”
namespace :famfam do
desc “famfam icons and stylesheets in application”
task :install => :environment do
puts "Copying famfam icons from …/assets/icons to " + RAILS_ROOT

  • “/public/styles”
    FileUtils.cd ‘…’
    puts FileUtils.pwd
    puts File.dirname(FILE)
    File.cp “/assets/icons”, RAILS_ROOT + “/public/styles”
    end
    end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs