Skip to content

Instantly share code, notes, and snippets.

@rohitarondekar
Created January 27, 2011 04:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohitarondekar/798094 to your computer and use it in GitHub Desktop.
Save rohitarondekar/798094 to your computer and use it in GitHub Desktop.
your_rails_app/script/runner
======
#!/usr/bin/env ruby
path_to_rails = File.dirname(File.expand_path(__FILE__))
exec("#{path_to_rails}/rails runner #{ARGV[0]}")
======
You can just drop it in your_rails_app/script/runner — chmod +x the file and use it in place of rails runner. The main advantage of using this is that you can use it in your script files using a shebang:
======
#!/usr/bin/env /home/rohit/code/runmeapp/script/runner
Product.find(:all).each { |p| p.price *= 2 ; p.save! }
======
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment