Railsエンジンの開発を練習するために、Comatose用のRails3.2.8エンジンを開発しています。私は奇妙な問題に遭遇しました、そして私は他の誰かがそれに遭遇したかどうか疑問に思います。主な問題は、ActionDispatch :: Routing :: RouteSet#eval_blockにあります。メソッドがMapper.newを呼び出すと、「引数の数が間違っています(0の場合は1)」という例外が発生します。現在の定義は次のとおりです。
def eval_block(block)
if block.arity == 1
raise "You are using the old router DSL which has been removed in Rails 3.1. " <<
"Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/"
end
mapper = Mapper.new(self)
if default_scope
mapper.with_default_scope(default_scope, &block)
else
mapper.instance_exec(&block)
end
end
デバッガーブレークポイントから、マッパーはActionDispatch :: Routing :: RouteSet :: Mapperであり、ActionDispatch :: Routing::Mapperではありません。ただし、ActionDispatch :: Routing :: RouteSet::Mapperがどこにも定義されていません。
Mapperが実際にいくつかの宝石によってRouteSet内で定義されているところで、動的なRuby /RailsMagicが発生しているかどうかはわかりません。それを追跡できないようです。grepでgemset全体で「Mapper」を検索しましたが、何も見つかりませんでした。
Mapperが完全に修飾されるように、実際にはtest / dummy / config/initializerのイニシャライザーを使用してコードで回避策を作成する必要がありました。
::ActionDispatch::Routing::RouteSet.class_eval do
def eval_block(block)
if block.arity == 1
raise "You are using the old router DSL which has been removed in Rails 3.1. " <<
"Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/"
end
mapper = ::ActionDispatch::Routing::Mapper.new(self)
if default_scopeSo,
mapper.with_default_scope(default_scope, &block)
else
mapper.instance_exec(&block)
end
end
end
他のプロジェクトでこれまでこのエラーに遭遇したことはありません。これは、フレームワーク内でエンジンをテストする最初の試みですが、他のプロジェクトで以前にエンジンを使用したことがあります。コードはRails3.2.7でも同じように見えます。
他の誰かが問題に遭遇したことがありますか、それとも私は完全に間違ったことをしていますか?私はRuby1.9.3-p194、Rails 3.2.8、そしてもちろん多くの宝石を使用しています。私は完全に更新されたUbuntu12.04を使用しており、RVMを使用しています。バンドラーからの宝石は、私が使用していると言っています:
Using rake (0.9.2.2)
Using RedCloth (4.2.9)
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.8)
Using builder (3.0.1)
Using activemodel (3.2.8)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.8)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.8)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.8)
Using activeresource (3.2.8)
Using acts_as_list (0.1.8)
Using acts_as_tree (1.1.0)
Using acts_as_versioned (0.2.3)
Using bundler (1.2.0)
Using cocaine (0.3.0)
Using columnize (0.3.6)
Using rack-ssl (1.3.2)
Using json (1.7.5)
Using rdoc (3.12)
Using thor (0.16.0)
Using railties (3.2.8)
Using jquery-rails (2.1.1)
Using rails (3.2.8)
Using comatose (0.0.1) from source at .
Using daemons (1.1.9)
Using debugger-ruby_core_source (1.1.3)
Using debugger-linecache (1.1.2)
Using debugger (1.2.0)
Using eventmachine (0.12.10)
Using liquid (2.4.1)
Using paperclip (3.1.4)
Using responds_to_parent (1.1.0)
Using sqlite3 (1.3.6)
Using test-unit (2.5.2)
Using thin (1.4.1)
これはRailsで取り上げる問題ですか?もしそうなら、どこでそれを行いますか?私が理解していないRubyの誤解されたスコープルールですか?同様に、なぜMapperは、ActionDispatch :: RoutingモジュールでMapperクラスを参照するのではなく、ActionDispatch :: Routing :: RouteSetモジュールで存在しないクラスを参照するのですか?
ありがとう、-Polar