2012-09-07 3 views
0

레일즈 엔진 개발을위한 연습을 위해 Comatose 용 Rails 3.2.8 엔진을 개발 중입니다. 나는 이상한 문제에 부 닥쳤다. 그리고 나는 다른 사람도 그것에 부딪쳤는 지 궁금해하고있다. 주요 문제는 ActionDispatch :: Routing :: RouteSet # eval_block에 있습니다. 내가 인수의 잘못된 번호 "의 예외 방법은 Mapper.new를 호출 (0 1)을 얻을 여기에 현재 정의입니다 :. 디버거 중단 점에서Rails 3.2.8 : ActionDispatch :: Routing :: RouteSet :: Mapper, 존재합니까?

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 :: 라우팅이다 :: RouteSet : : Mapper, and ActionDispatch :: Routing :: Mapper. 그러나 어디서나 정의 된 ActionDispatch :: Routing :: RouteSet :: Mapper를 찾을 수 없습니다.

일부 동적 Ruby/Rails Magic이 발생하는지 잘 모르겠습니다. Mapper는 실제로 일부 보석에 의해 RouteSet 내부에서 정의되었습니다. 그걸 추적 할 수 없으며 전체 보석에서 "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 

다른 프로젝트에서는이 오류가 발생하지 않았습니다. 이것은 프레임 워크 내에서 엔진을 테스트하는 첫 번째 시도이지만 다른 프로젝트에서는 이전에 Engines를 사용했습니다. 이 코드는 Rails 3.2.7에서도 동일하게 보입니다.

문제가있는 사람이 있습니까? 아니면 완전히 잘못하고있는 사람이 있습니까? 저는 Ruby 1.9.3-p194, Rails 3.2.8 그리고 수많은 보석을 사용하고 있습니다. 나는 Ubuntu 12.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) 

이 레일에 제기 할 수있는 문제인가, 그렇다면, 내가 그 어디해야합니까 다음과 같이 들러에서 보석 말한다 내가 사용은? 루비에 대한 이해 범위가 잘못 이해하고 있습니까? 마찬가지로, Mapper는 ActionDispatch :: Routing 모듈의 Mapper 클래스를 참조하는 대신 ActionDispatch :: Routing :: RouteSet 모듈에서 존재하지 않는 클래스를 참조하는 이유는 무엇입니까?

덕분에, - 북극

답변

0

난 그냥 같은 문제 다 퉜다.

class ActionController::Routing::RouteSet::Mapper 
    def from_plugin(name) 
    eval File.read(File.join(RAILS_ROOT, "vendor/plugins/#{name}/routes.rb")) 
    end 
end 

문제의 원인 : 내 경우

, 그것은 다음과 같은 코드를 가진 오래된 플러그인 (미개한 짐승)에 의해 발생했다. 아마도 이것이 도움이 될 수 있습니다. Rails.root 대신 오래된 RAILS_ROOT 때문에 문제가 발생했다고 생각합니다.

관련 문제