0

古い W​​eb サイトを Heroku にデプロイしようとしています。すべてがうまくいき、起動しますが、Webブラウザーからアクセスすると、

NameError (uninitialized constant ApplicantsController::GeoIP):

私はRails 2.3.18を使用しています(私のウェブサイトは非常にシンプルで、「そのまま」そしてできるだけ早くデプロイしたいだけです。専用サーバーではすべてうまくいきました)。

「db」フォルダーと controllers/applicants_controller.rb に GeoIP.dat ファイルがあります。

line 32:    geoip ||= GeoIP.new("db/GeoIP.dat")
line 33:    location = geoip.country('google.com')

Heroku で irb を起動すると、すべて問題なく表示されます。

login@sancho:~$ heroku run bash
Running `bash` attached to terminal... up, run.7785
~ $ irb
irb(main):001:0> require 'geoip'
=> true
irb(main):002:0> geoip ||= GeoIP.new("db/GeoIP.dat")
=> #<GeoIP:0x00000002b3a6a8 @mutex=#<Mutex:0x00000002b3a680>, @flags=0, @database_type=1, @record_length=3, @file=#<File:db/GeoIP.dat>, @database_segments=[16776960]>
irb(main):004:0> geoip.country('google.com')
=> #<struct GeoIP::Country request="google.com", ip="74.125.228.110", country_code=225, country_code2="US", country_code3="USA", country_name="United States", continent_code="NA">
irb(main):005:0> 

ここに完全なエラーログがあります。

2013-05-02T13:08:25.938481+00:00 app[web.1]: Processing ApplicantsController#create (for 87.207.27.219 at 2013-05-02 13:08:25) [POST]
2013-05-02T13:08:25.938481+00:00 app[web.1]:   Parameters: {"status"=>"complete"}
2013-05-02T13:08:26.029730+00:00 app[web.1]: 
2013-05-02T13:08:26.029730+00:00 app[web.1]: NameError (uninitialized constant ApplicantsController::GeoIP):
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:131:in `rescue in const_missing'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/flash.rb:151:in `perform_action_with_flash'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:87:in `dispatch'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:121:in `_call'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:29:in `block in call'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/session/cookie_store.rb:99:in `call'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   <internal:prelude>:10:in `synchronize'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:120:in `const_missing'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:532:in `process'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:130:in `block in build_middleware_stack'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   app/controllers/applicants_controller.rb:32:in `create'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:391:in `process'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/filters.rb:617:in `call_filters'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:386:in `call'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/base.rb:1333:in `perform_action'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/filters.rb:606:in `process_with_filters'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:29:in `call'
2013-05-02T13:08:26.029730+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
2013-05-02T13:08:26.030057+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/routing/route_set.rb:438:in `call'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:9:in `cache'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:28:in `call'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/params_parser.rb:15:in `call'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/string_coercion.rb:25:in `call'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:54:in `process'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:106:in `call'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2013-05-02T13:08:26.030520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2013-05-02T13:08:26.030298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-2.3.18/lib/action_controller/failsafe.rb:26:in `call'
2013-05-02T13:08:26.030750+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.5.1/lib/thin/controllers/controller.rb:86:in `start'
2013-05-02T13:08:26.030750+00:00 app[web.1]: Rendering /app/public/500.html (500 Internal Server Error)

Heroku からのバンドル ログ:

   Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
   The source :gemcutter is deprecated because HTTP requests are insecure.
   Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
   Using rake (0.8.7)
   Using activesupport (2.3.18)
   Using rack (1.1.6)
   Using actionpack (2.3.18)
   Using actionmailer (2.3.18)
   Using activerecord (2.3.18)
   Using activeresource (2.3.18)
   Using daemons (1.1.9)
   Using eventmachine (1.0.3)
   Using geoip (1.2.1)
   Using pg (0.15.1)
   Using rails (2.3.18)
   Using thin (1.5.1)
   Using bundler (1.3.2)
   Your bundle is complete! It was installed into ./vendor/bundle

よろしくお願いします。

4

1 に答える 1

0

問題が解決しました。

ここで説明されているように、config/boot.rb を編集して edit/preinitializer.rb を作成するのを忘れていましたhttp://gembundler.com/v1.3/rails23.html

于 2013-05-02T14:15:43.587 に答える