我试图在我的项目中使用newrelic。我已经成功安装了newrelic gem,下一步是添加config.gem" newrelic_rpm"到environment.rb
当我在environment.rb中使用config.gem时,我无法启动 Ruby on Rails应用程序但是使用 config.gem" dfgdsgsdgsdfg" 会导致同样的错误。
我该如何解决这个问题?
我正在运行Debian Linux,Apache2,RVM 1.8.6,Passenger 3,Rails 2.3.5,Ruby 1.8.7,gem 1.8.10
这是我的environment.rb
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.gem "newrelic_rpm"
config.time_zone = 'UTC'
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_content_type = "text/html"
config.action_mailer.smtp_settings = {
:address => "smtp.xxx.xx",
:port => 25,
:domain => "xxxx.com",
:authentication => :login,
:user_name => "site@xxxxx.com",
:password => "xxxxx"
:enable_starttls_auto => true
}
end
和完全回溯
Ruby on Rails application could not be started
Error message:
undefined method `name' for "actionmailer":String
Exception class:
NoMethodError
Application root:
/var/www/ytndweb/data/www/rc.xxxx.xx
Backtrace:
# File Line Location
0 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/rails/gem_dependency.rb 268 in `=='
1 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 217 in `==='
2 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 217 in `matching_specs'
3 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 36 in `find_all'
4 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/specification.rb 410 in `each'
5 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/specification.rb 409 in `each'
6 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 216 in `find_all'
7 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 216 in `matching_specs'
8 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 238 in `to_specs'
9 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/dependency.rb 256 in `to_spec'
10 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems.rb 1210 in `gem'
11 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/rails/gem_dependency.rb 73 in `add_load_paths'
12 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 301 in `add_gem_load_paths'
13 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 301 in `each'
14 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 301 in `add_gem_load_paths'
15 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 132 in `process'
16 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 113 in `send'
17 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/rails-2.3.5/lib/initializer.rb 113 in `run'
18 /var/www/ytndweb/data/www/rc.yetonado.ru/config/environment.rb 10
19 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 36 in `gem_original_require'
20 /usr/local/rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 36 in `require'
21 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in `preload_application'
22 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/classic_rails/application_spawner.rb 181 in `initialize_server'
23 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/utils.rb 572 in `report_app_init_status'
24 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/classic_rails/application_spawner.rb 174 in `initialize_server'
25 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb 204 in `start_synchronously'
26 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb 180 in `start'
27 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/classic_rails/application_spawner.rb 149 in `start'
28 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb 219 in `spawn_rails_application'
29 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
30 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb 214 in `spawn_rails_application'
31 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb 82 in `synchronize'
32 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize'
33 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb 213 in `spawn_rails_application'
34 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb 132 in `spawn_application'
35 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
36 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb 357 in `__send__'
37 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
38 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
39 /usr/local/rvm/gems/ruby-1.8.7-p352/gems/passenger-3.0.9/helper-scripts/passenger-spawn-server 99
答案 0 :(得分:3)
前言:我为New Relic工作。
而不是使用config.gem只需添加:
require "newrelic_rpm"
在初始化程序之后它应该工作得很好:)我希望我有理由为什么你必须这样做,但我不这样做。当我还在使用Rails 2.x应用程序时,我记得这只是一个“技巧”(我从来没有好运过config.gem)。