2012-11-21 4 views
8

그래서 나는 몽고 먹거리로 놀고 있습니다. 새로운 heroku 앱을 만들었고 mongolab 옵션을 추가했지만 모든 mongoid 메소드가 실패합니다.홍골수가 루비에서 실패 1.9.3

주위를 둘러 보았습니다.이 문제는 1.9.3 이전의 루비와 공통적 이었지만 1.9.3을 실행 중입니다. 내가합니다 (mongolab의 DB에 대해) 로컬로 실행 여기서 얻으실 수

require 'sinatra' 
require 'mongoid' 
require 'json' 
require "sinatra/reloader" if development? 

Mongoid.load!("mongoid.yml") 

class Company 
    include Mongoid::Document 

    field :code, type: String 
    field :sector, type: String 
    field :share_id, type: Integer 
    field :jse_code, type: Integer 
end 

get '/' do 
    "Hello" 
end 

get '/company' do 
    Company.exists? 
end 

나에게 Heroku에, 나는 오류 같은 종류의 수 :

다음은 간단한 실패 샘플의

12:22:33 web.1 | NoMethodError - undefined method `match' for nil:NilClass: 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions/mongo_uri.rb:49:in `initialize' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:103:in `new' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:103:in `parse' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:62:in `create_session' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions/factory.rb:43:in `default' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:109:in `default' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:378:in `__session__' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:213:in `mongo_session' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/sessions.rb:157:in `collection' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual/mongo.rb:216:in `initialize' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual.rb:47:in `new' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual.rb:47:in `create_context' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual.rb:30:in `context' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual.rb:20:in `rescue in exists?' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/contextual.rb:18:in `exists?' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/mongoid-3.0.13/lib/mongoid/finders.rb:43:in `exists?' 
12:22:33 web.1 | app.rb:22:in `block in <main>' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block in compile!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 levels) in route!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 levels) in route!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in process_route' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `process_route' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in route!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in call!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in invoke' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `invoke' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `call!' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/logger.rb:15:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:129:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/head.rb:9:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/showexceptions.rb:21:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `block in call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1471:in `synchronize' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/thin-1.5.0/lib/thin/connection.rb:81:in `block in pre_process' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/thin-1.5.0/lib/thin/connection.rb:79:in `catch' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/thin-1.5.0/lib/thin/connection.rb:79:in `pre_process' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.0/lib/eventmachine.rb:1037:in `call' 
12:22:33 web.1 | /Users/sdx/.rvm/gems/ruby-1.9.3-p327/gems/eventmachine-1.0.0/lib/eventmachine.rb:1037:in `block in spawn_threadpool' 
12:22:33 web.1 | 127.0.0.1 - - [21/Nov/2012 12:22:33] "GET /__sinatra__/500.png HTTP/1.1" 200 31056 0.0062 

어떻게 생각을 잘못하고있는거야? 스택을 기반으로

production: 
    sessions: 
     default: 
      uri: <%= ENV['MONGOLAB_URI'] %> 
      options: 
       skip_version_check: true 
       safe: true 
development: 
    sessions: 
     default: 
      uri: <%= ENV['MONGOLAB_URI'] %> 

답변

9

mongo_uri null 값을 전달되는 것이 생성자처럼 보인다 추적 :

업데이트] 여기 내 mongoid.yml입니다. 나는 당신의 mongoid.yml에서 다음을 확인 것 :이 환경 변수를 참조하는 경우 올바르게

  • 를 구성 할 것
  • 바로 이곳에

    • 은 바로 이곳에 있어요/인수 load! 포인트 (예 : MONGOLAB_URI

      다음 MongoLab Heroku가 부가) 그들이 환경에

    관련 라인을 설정하고 그 예외가 발생되고 mongo_uri.rb:49에서 대한

    # Create the new uri from the provided string. 
        # 
        # @example Create the new uri. 
        # MongoUri.new(uri) 
        # 
        # @param [ String ] string The uri string. 
        # 
        # @since 3.0.0 
        def initialize(string) 
        @match = string.match(URI) 
        end 
    
  • +0

    나는 나의 mongoid.yml 파일로 질문을 업데이트했습니다. 나는 그것을 읽는 것이 확실하다. 기본 값이 없거나 env 변수가 틀리면 –

    +0

    당신이 옳았습니다. 로컬에서는 연결 문제였습니다. 그리고 서버에서, 나의 Gemfile이 말한 것과는 달리 1.9.1을 사용하고있었습니다. 그래서, 2 가지 다른 이슈가 완벽한 혼란을 가져 왔습니다. –