Skip to content

Instantly share code, notes, and snippets.

@oleksiilevzhynskyi
Forked from gnepud/gist:1429965
Created May 13, 2012 20:44
Show Gist options
  • Save oleksiilevzhynskyi/2690092 to your computer and use it in GitHub Desktop.
Save oleksiilevzhynskyi/2690092 to your computer and use it in GitHub Desktop.
Launch Pry in Rails project
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry instead.
# If you don't, you can load it through the lines below :)
rails = File.join Dir.getwd, 'config', 'environment.rb'
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == "2"
require 'console_app'
require 'console_with_helpers'
elsif Rails.version[0..0] == "3"
require 'rails/console/app'
require 'rails/console/helpers'
# Show sql output
ActiveRecord::Base.logger = Logger.new(STDOUT)
# Add reload! command if rails version > 3.2
if Rails.version[2..2].to_i >= 2
include Rails::ConsoleMethods
end
else
warn "[WARN] cannot load Rails console commands (Not on Rails2 or Rails3?)"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment