我需要帮助来获取在 Ubuntu 11.10 服务器上运行的 rails 应用程序。
我已经使用了大约 2 天,无法超越此处屏幕截图中显示的部分。据我所知,我已经正确安装了 rvm、rails、ruby、capistrano、fusion 乘客。我认为我的问题与数据库(mysql)或让rails与数据库通信有关(我只是从下面的错误消息中猜测)。
Error message:
undefined method `active_record' for #<Rails::Application::Configuration:0x00000002e43fe8>
Exception class:
NoMethodError
Application root:
/var/www/jamesbay/blog/current
我的主要问题是如何进行调试?我已尝试修改 config.ru 文件、application.rb 和 environment.rb,但没有解决。我不完全确定这些错误甚至意味着什么!
我已将 capistrano 正确部署到服务器上的目录中。我可以更新 git repo 并使用各种“cap”命令来处理从本地机器到服务器的实际部署。
任何帮助表示赞赏!(我只使用了大约 2 周的 Rails,并且由于这个项目,我已经学习了关于服务器管理的 TON)
错误
0 /usr/local/rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configuration.rb 85 in `method_missing'
1 /home/jamesbay/blog/releases/20121026055113/config/application.rb 54 in `'
2 /home/jamesbay/blog/releases/20121026055113/config/application.rb 13 in `'
3 /home/jamesbay/blog/releases/20121026055113/config/application.rb 12 in `'
4 /home/jamesbay/blog/releases/20121026055113/config/environment.rb 2 in `require'
5 /home/jamesbay/blog/releases/20121026055113/config/environment.rb 2 in `'
6 config.ru 3 in `require'
7 config.ru 3 in `block in '
8 /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb 51 in `instance_eval'
9 /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb 51 in `initialize'
10 config.ru 1 in `new'
11 config.ru
设置
Rails 3.2.8
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
rvm 1.16.17 (stable)
Capistrano 2.13.4
Phusion Passenger 3.0.17
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rvm/gems/ruby-1.9.3-p194
- /usr/local/rvm/gems/ruby-1.9.3-p194@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Gems 使用 actionmailer (3.2.8) actionpack (3.2.8) activemodel (3.2.8) activerecord (3.2.8) activeresource (3.2.8) activesupport (3.2.8) arel (3.0.2) bcrypt-ruby (3.0. 1) builder (3.0.4) bundler (1.2.1) capistrano (2.13.4) coffee-rails (3.2.2) coffee-script (2.2.0) coffee-script-source (1.4.0) erubis (2.7. 0) execjs (1.4.0) highline (1.6.15) hike (1.2.1) i18n (0.6.1) Journey (1.0.4) jquery-rails (2.1.3) json (1.7.5) mail (2.4. 4) mime-types (1.19) multi_json (1.3.6) mysql2 (0.3.11) net-scp (1.0.4) net-sftp (2.0.5) net-ssh (2.6.1) net-ssh-gateway ( 1.1.0) polyglot (0.3.3) rack (1.4.1) rack-cache (1.2) rack-ssl (1.3.2) rack-test (0.6.2) rails (3.2.8) railties (3.2.8) rake (0.9.2.2) rdoc (3.12) rubygems-bundler (1.1.0) rvm (1.11.3.5) sass (3.2.1) sass-rails (3.2.5) sprockets (2.1.3) sqlite3 (1.3.6)雷神 (0.16.0) 倾斜 (1.3.3) 树顶 (1.4.11) tzinfo (0.3.33) 丑化者 (1.3.0)
--
这是刚才在浏览器中打开应用程序后日志文件中显示的内容:
[Fri Oct 26 07:46:15 2012] [notice] Graceful restart requested, doing restart
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/mcrypt.so' - /usr/lib/php5/20090626/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Fri Oct 26 07:46:15 2012] [notice] Apache/2.2.20 (Ubuntu) DAV/2 SVN/1.6.12 PHP/5.3.6-13ubuntu3.7 with Suhosin-Patch Phusion_Passenger/3.0.17 configured -- resuming normal operations
[ pid=30885 thr=4411480 file=utils.rb:176 time=2012-10-26 12:56:40.708 ]: *** Exception NoMethodError in PhusionPassenger::Rack::ApplicationSpawner (undefined method `active_record' for #<Rails::Application::Configuration:0x00000001931f38>) (process 30885, thread #<Thread:0x0000000086a0b0>):
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configuration.rb:85:in `method_missing'
from /home/jamesbay/blog/releases/20121026055113/config/application.rb:54:in `<class:Application>'
from /home/jamesbay/blog/releases/20121026055113/config/application.rb:13:in `<module:Blog>'
from /home/jamesbay/blog/releases/20121026055113/config/application.rb:12:in `<top (required)>'
from /home/jamesbay/blog/releases/20121026055113/config/environment.rb:2:in `require'
from /home/jamesbay/blog/releases/20121026055113/config/environment.rb:2:in `<top (required)>'
from config.ru:3:in `require'
from config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:225:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:225:in `load_rack_app'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:157:in `block in initialize_server'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/utils.rb:563:in `report_app_init_status'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:154:in `initialize_server'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:204:in `start_synchronously'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
from <internal:prelude>:10:in `synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/helper-scripts/passenger-spawn-server:99:in `<main>'
在切换到 rails 1.9.3-p194(与我的开发机器相同)并删除 p286 后,当我进入我的站点时,我收到一条消息,说“您正在寻找的页面不存在”在 RED 中。
这是 error.log 文件的输出:
Rails Error: Unable to access log file. Please ensure that /home/jamesbay/blog/releases/20121026205006/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
ActionController::RoutingError (No route matches [GET] "/jamesbay"):
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'
passenger (3.0.17) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
passenger (3.0.17) lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
passenger (3.0.17) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
passenger (3.0.17) lib/phusion_passenger/utils.rb:470:in `safe_fork'
passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:180:in `start'
passenger (3.0.17) lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
passenger (3.0.17) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
passenger (3.0.17) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
passenger (3.0.17) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
passenger (3.0.17) helper-scripts/passenger-spawn-server:99:in `<main>'