Enabling Pry with reload
程序员文章站
2022-07-15 11:50:08
...
For anyone coming to this question recently: the answer has changed in Rails 3.2, because they've changed how they implement reload!
Where in earlier version the irb commands were added as methods to Object
, now they are added to IRB::ExtendCommandBundle
to avoid polluting the global namespace.
What I do now is (1) in development.rb
silence_warnings do
begin
require 'pry'
IRB = Pry
module Pry::RailsCommands ;end
IRB::ExtendCommandBundle = Pry::RailsCommands
rescue LoadError
end
end
and (2) in .pryrc
if Kernel.const_defined?("Rails") then
require File.join(Rails.root,"config","environment")
require 'rails/console/app'
require 'rails/console/helpers'
Pry::RailsCommands.instance_methods.each do |name|
Pry::Commands.command name.to_s do
Class.new.extend(Pry::RailsCommands).send(name)
end
end
end
Here's the link to the Rails pull request where the change was introduced -https://github.com/rails/rails/pull/3509
推荐阅读
-
how to save a pytorch model and reload it from the pickle file
-
python中reload用法实例
-
window.location.reload 刷新使用分析(去对话框)
-
vue this.reload 方法 配置
-
在vue中使用[provide/inject]实现页面reload
-
window.location.reload 刷新使用分析(去对话框)
-
vue this.reload 方法 配置
-
Enabling Pry with reload
-
Keras学习(八)——save & reload
-
火狐浏览器不支持location.reload()