0

コントローラーで呼び出される Configuration というクラスがあります。Configuration クラスをインスタンス化する代わりに、ActiveSupport::Configurable::Configuration.

別のライブラリと同じ名前のクラスにアクセスするには どうすればよいですか?ConfigurationConfiguration

class SampleController < ActionController::Base
  def m1
    cfg = Configuration.new
  end
end
4

1 に答える 1

1
class SampleController < ActionController::Base
  def m1
    cfg = ::Configuration.new
  end
end

ただし、独自のクラスを独自のモジュールに入れることをお勧めします。

このようなクラス名の競合を回避するだけでなく、独自のコードをさらにハングアップできる構造を提供します。

于 2013-06-17T17:38:07.880 に答える