File.open, write and save?

If you just need to perform a simple script like creating a file, you can simply use a Ruby script without creating a rake task. # file origin.rb target = “target.rb” content = <<-RUBY puts “I’m the target!” RUBY File.open(target, “w+”) do |f| f.write(content) end And you can execute the file with $ ruby origin.rb

How can I pass an array as an argument to a Rake task?

One of the soulutions is to avoid , symbol in the string, so your command line would look like: $ rake change_statuses[‘1 2 3’, foo, bar] Then you can simply split the IDs: # Rakefile task :change_statuses, :ids, :current_status, :new_status do |task, args| ids = args[:ids].split ‘ ‘ puts “args were #{args.inspect}” puts “ids were … Read more

Asking questions in rake tasks

task :input_test do input=”” STDOUT.puts “What is the airspeed velocity of a swallow?” input = STDIN.gets.chomp raise “bah, humbug!” unless input == “an african or european swallow?” end task :blah_blah => :input_test do end i think that should work

How to debug a Rails asset precompile which is unbearably slow

This may not entirely answer your question, but I believe it is a decent enough start. As you’ll see, the precise answer will depend on the individual application, gem versions and so on. So. For asset-related work, as you know, Rails uses a library called Sprockets, which in newer versions of Rails is, I believe, … Read more

How to rake db:drop and rake db:create on Heroku? [duplicate]

The pg:reset command will recreate the database for you. Example usage: $ heroku config | grep POSTGRESQL HEROKU_POSTGRESQL_RED_URL: postgres://somedatabaseurl $ heroku pg:reset HEROKU_POSTGRESQL_RED_URL ! WARNING: Destructive Action ! This command will affect the app: myappname ! To proceed, type “myappname” or re-run this command with –confirm > myappname Resetting HEROKU_POSTGRESQL_RED_URL (DATABASE_URL)… done The db:reset command … Read more