namespace :retail_stock do script_base_path = File.join(File.dirname(File.expand_path(__FILE__)), "../../support/") desc "Load retail stock from CSV file" task :load => [:environment] do |task| path = File.join(script_base_path, "retail_stock_upload_script.rb") # Referencing an ActiveRecord class triggers the actual loading of that class so it can then be used within the script. # Without this, the ActiveRecord models aren't loaded, even with the ":environment" dependency CatalogItem Site Watch puts "Loading retail stock with script at #{path}" load path end end