我试图将一个完整的文件夹添加到我的Rails应用程序的JRuby 1.5类路径中。 JRuby Wiki 建议如下: "...在config/environment.rb
中将配置目录添加到JRuby类路径中:"
$CLASSPATH << "file:///#{File.expand_path(File.join(RAILS_ROOT, 'config'))}/"
对我似乎不起作用。无论我把它放在Rails::Initializer.run
块的前面、后面还是里面都没关系。无论如何,我都会得到:
/home/sean/src/sbruby/seo/config/environment.rb:45:NoMethodError: undefined method `<<' for nil:NilClass
/home/sean/apps/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.7/lib/rails/backtrace_cleaner.rb:2:NameError: uninitialized constant ActiveSupport::BacktraceCleaner
/home/sean/apps/jruby/jruby-1.5.0/lib/ruby/gems/1.8/gems/rails-2.3.7/lib/console_with_helpers.rb:5:NameError: uninitialized constant ApplicationController
例如,我想在RAILS_ROOT
下添加一个名为resources/foobar
的文件夹,因此我在environment.rb
中添加了以下内容:$CLASSPATH << "file:///#{File.expand_path(File.join(RAILS_ROOT, "resources", "foobar"))}/"
同样的错误。
在Rails中,如何正确地将一个文件夹添加到JRuby类路径中?