Skip to content

Instantly share code, notes, and snippets.

@bergpb
Forked from sarahhodne/gist:1341827
Created August 21, 2018 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergpb/28a6044ac2c51ecaa9e395c1dae34ff6 to your computer and use it in GitHub Desktop.
Save bergpb/28a6044ac2c51ecaa9e395c1dae34ff6 to your computer and use it in GitHub Desktop.
Use pry for rails console
# 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'
else
warn '[WARN] cannot load Rails console commands (Not on Rails 2 or 3?)'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment