Skip to content

Commit

Permalink
Merge pull request #130 from melopilosyan/rails-7_2
Browse files Browse the repository at this point in the history
Adds support for Rails version >= 7.2
  • Loading branch information
rf- authored Jun 20, 2024
2 parents 12a517e + 88a8f1a commit c7647d2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/pry-rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,33 @@ class Railtie < Rails::Railtie
Rails.application.config.console = Pry
end

if (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 2) ||
Rails::VERSION::MAJOR >= 4
major = Rails::VERSION::MAJOR
minor = Rails::VERSION::MINOR

if (major == 3 && minor >= 2) || (major >= 4 && (major < 7 || (major == 7 && minor < 2)))
require "rails/console/app"
require "rails/console/helpers"
TOPLEVEL_BINDING.eval('self').extend ::Rails::ConsoleMethods
end

if major > 7 || (major == 7 && minor >= 2)
require "rails/commands/console/irb_console"

Module.new do
def reload!
puts "Reloading..."
Rails.application.reloader.reload!
end

::IRB::HelperMethod.helper_methods.each do |name, helper_method_class|
define_method name do |*args, **opts, &block|
helper_method_class.instance.execute(*args, **opts, &block)
end
end

TOPLEVEL_BINDING.eval("self").extend self
end
end
end
end
end

0 comments on commit c7647d2

Please sign in to comment.