Kristian
2009-Sep-09 07:17 UTC
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
Maybe Matching Threads
- rake assets:precompile issue with JS and stylesheets files with similar name
- Rails 3.1, stylesheet assets not being reloaded correctly?
- Automatic asset paths prevent logical asset organization
- ActionView::Template::Error Not a directory vendor/assets/javascripts/ production
- Making Mongrel/WEBRick serve static assets with future expires header