我已按照rack-recaptcha readme中所述的步驟進行操作。無法通過「rack-recaptcha」啓動服務器gem
我已經完成了所有的步驟,而不是「你必須在你的gemfile中需要'rack-recaptcha'」。
服務器無法啓動,因爲有下列錯誤:
Booting Mongrel => Rails 2.3.5 application starting on http://127.0.0.1:3001 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load_missing_constant' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing' /{path_to_my_project}/config/environment.rb:29 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:111:in `run' /{path_to_my_project}/config/environment.rb:9 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' ./script/server:3 /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_load' /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in `debug_program' /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/bin/rdebug-ide:87 /usr/bin/rdebug-ide:19:in `load' /usr/bin/rdebug-ide:19 -e:2:in `load' -e:2 Uncaught exception: uninitialized constant Rack::Recaptcha
我認爲,用「的Gemfile」的一步,我是跳過的,這是錯誤的原因。
但是,我不知道,我應該在哪裏尋找提到的「gemfile」?
幫助,請
更新:
的environment.rb是繼
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
#config.load_paths += %W(#{RAILS_ROOT}/extras)
config.load_paths += %W(#{RAILS_ROOT}/public)
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# NOTE: jquery.js must be updated to the latest version 1.4.2
# to avoid differences in behaviour of HTML makeup and Rails
config.gem 'jrails'
config.gem 'nokogiri
config.gem 'uuid
config.gem 'rack-recaptcha', :lib => 'rack/recaptcha'
config.middleware.use Rack::Recaptcha, :public_key => 'my_secret', :private_key => 'my_secret', :paths => 'http://localhost:3001/my_controller'
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
config.active_record.observers = :user_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
config.i18n.default_locale = :ru
end
我已初步完成的正是這一點,但它抱怨排隊: /{path_to_my_project}/config/environment.rb:29 其中包含 配置.middleware.use Rack :: Recaptcha,:public_key =>'KEY',:private_key =>'SECRET',:paths =>'PATH' 它仍然無法正常工作,顯示相同的錯誤 – AntonAL 2010-07-21 10:48:37
而且您確定在你的'config.middleware.use'行之前'config.gem'行出現**? – bjg 2010-07-21 10:59:56
是的,我確定。我已將列表添加到我的問題中。 – AntonAL 2010-07-21 11:08:06