有没有人可以建议一些在win32下运行irbrc的故障排除方法?rails控制台是一个很棒的工具,我正试图用更多的功能来扩展它。
例如,我希望自动加载what_method gem。gem已安装但未加载:

C:\...\trunk>ruby script\console
Loading development environment (Rails 2.3.2)
>> 3.45.what? 3
NoMethodError: undefined method `what?' for 3.45:Float
        from (irb):1
>> require 'what_methods'
=> ["DummyOut", "WhatMethods"]
>> 3.34.what? 3
3.34.round_with_precision == 3
...
=> ["round_with_precision", "round", "prec_i", ... "round_without_precision"]
>>

我的环境设置为
C:\...\trunk>dir %HOME%
 Volume in drive C is OS
...
06/21/2009  10:29 AM    <DIR>          .
06/21/2009  09:28 AM               118 .irbrc
...

环境变量路径irbrc=%home%\.irbrc
IRBR文件
require 'irb/completion'
require 'map_by_method'
require 'what_methods'
require 'pp'
IRB.conf[:AUTO_INDENT]=true

我读过以下参考资料
http://railscasts.com/episodes/48-console-tricks
http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/#irbrc_win32
http://groups.google.com/group/ruby-talk-google/browse_thread/thread/23fe3980a5a4816e
http://www.nabble.com/.irbrc-on-Windows-td23954309.html

最佳答案

如果您希望在rails环境中自动加载“what_methods”gem,只需在rails_root\config\environment.rb内的rails配置中通过config.gem指定它:

Rails::Initializer.run do |config|
...
  config.gem "what_methods"
...
end

或者只用于开发,只需将其添加到rails\u root\config\environments\development.rb中:
config.gem "what_methods"

关于ruby-on-rails - 如何使IRBRC在Win32 for Ruby控制台上运行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1024056/

10-13 02:19