Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created February 23, 2011 02:58
Show Gist options
  • Save technicalpickles/839919 to your computer and use it in GitHub Desktop.
Save technicalpickles/839919 to your computer and use it in GitHub Desktop.
Rails 3 Application Template for making RVM, RVM gemsets, Passenger, and ruby-debug play nice-nice
file "config/setup_load_paths.rb", <<FILE
# based on http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
FILE
file ".rvmrc", <<FILE
rvm --create use "#{ENV['rvm_ruby_string']}@#{app_name}"
FILE
# debugging info courtesy of: http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger
file "config/initializers/passenger-debug.rb", <<FILE
debug_file = Rails.root.join('tmp', 'debug.txt')
if Rails.env == 'development' && debug_file.exist?
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
debug_file.delete
end
FILE
gem "ruby-debug", :group => :test
file "lib/tasks/passenger.rake", <<FILE
task :restart do
system("touch tmp/restart.txt")
if ENV["DEBUG"] == 'true'
system("touch tmp/debug.txt")
puts "To continue debugging:"
puts " * hit the development url"
puts " * run 'rdebug -c' from the command line"
end
end
FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment