Đối với bất cứ ai đến với câu hỏi này thời gian gần đây: câu trả lời đã thay đổi trong Rails 3.2, bởi vì họ đã thay đổi cách họ thực hiện reload!
đâu trong phiên bản trước đó các lệnh IRB được thêm vào như là phương pháp để Object
, bây giờ chúng được bổ sung đến IRB::ExtendCommandBundle
để tránh gây ô nhiễm không gian tên chung.
Những gì tôi làm bây giờ là (1) trong development.rb
silence_warnings do
begin
require 'pry'
IRB = Pry
module Pry::RailsCommands ;end
IRB::ExtendCommandBundle = Pry::RailsCommands
rescue LoadError
end
end
và (2) trong .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
Đây là liên kết với Rails kéo yêu cầu nơi sự thay đổi đã được giới thiệu - https://github.com/rails/rails/pull/3509
Cảm ơn, tất cả mọi người! –