Heroku + Rails + GeoIp =未初始化的常量GeoIP错误

问题描述 投票:0回答:1

我正在尝试将旧网站部署到Heroku。一切顺利,开始了,但是当我通过网络浏览器访问它时,我得到

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

感谢您的帮助!

我正在尝试将旧网站部署到Heroku。一切正常,它开始了,但是当我通过Web浏览器访问它时,我得到了NameError(未初始化的常量ApplicantsController :: GeoIP):I'...

ruby-on-rails heroku ruby-on-rails-2 geoip
1个回答
0
投票

问题已解决。


0
投票

问题已解决。

© www.soinside.com 2019 - 2024. All rights reserved.