require "pry-rails/version"

module PryRails
  begin
    require 'pry'

    if (defined?(::Rails::Console) and ::Rails::VERSION::MAJOR >= 3)
      class Railtie < ::Rails::Railtie
        silence_warnings do
          ::Rails::Console::IRB = Pry

          unless defined?(Pry::ExtendCommandBundle)
            Pry::ExtendCommandBundle = Module.new
          end

          if ::Rails::VERSION::MINOR >= 2
            require "rails/console/app"
            require "rails/console/helpers"
            TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
          end
        end
      end
    end
  rescue LoadError
  end
end

require 'pry'
require 'pry-rails/version'

module PryRails
  class Railtie < Rails::Railtie
    console do
      if Rails::VERSION::MAJOR == 3
        Rails::Console::IRB = Pry

        unless defined? Pry::ExtendCommandBundle
          Pry::ExtendCommandBundle = Module.new
        end
      end

      if Rails::VERSION::MAJOR == 4
        Rails.application.config.console = Pry
      end

      if (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 2) ||
          Rails::VERSION::MAJOR == 4
        require "rails/console/app"
        require "rails/console/helpers"
        TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
      end
    end
  end
end

Add support for Rails 4's config.console
Add support for Rails 4's config.console
