添加基本​​的html身份验证后无法启动mongrel

时间:2010-08-30 15:27:32

标签: ruby-on-rails

这是我尝试启动Mongrel时得到的输出:

root@marley:/home/rsouthard/projects/inventory# ruby script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/home/rsouthard/projects/inventory/app/controllers/application.rb:5:in `before_filters': wrong number of arguments (1 for 0) (ArgumentError)
    from /home/rsouthard/projects/inventory/app/controllers/application.rb:5
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:382:in `load_without_new_constant_marking'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:382:in `load_file'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:381:in `load_file'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:256:in `require_or_load'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:221:in `depend_on'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:133:in `require_dependency'
    from /home/rsouthard/projects/inventory/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:20
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `evaluate_method'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `each'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `send'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in `run_callbacks'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:559:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:559:in `prepare_dispatcher'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:173:in `process'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:112:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:112:in `run'
    from /home/rsouthard/projects/inventory/config/environment.rb:13
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    from /usr/lib/ruby/1.8/mongrel/rails.rb:147:in `rails'
    from /usr/lib/ruby/1.8/mongrel_rails:114:in `cloaker_'
    from /usr/lib/ruby/1.8/mongrel/configurator.rb:149:in `call'
    from /usr/lib/ruby/1.8/mongrel/configurator.rb:149:in `listener'
    from /usr/lib/ruby/1.8/mongrel_rails:100:in `cloaker_'
    from /usr/lib/ruby/1.8/mongrel/configurator.rb:50:in `call'
    from /usr/lib/ruby/1.8/mongrel/configurator.rb:50:in `initialize'
    from /usr/lib/ruby/1.8/mongrel_rails:85:in `new'
    from /usr/lib/ruby/1.8/mongrel_rails:85:in `run'
    from /usr/lib/ruby/1.8/mongrel/command.rb:212:in `run'
    from /usr/lib/ruby/1.8/mongrel_rails:282
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load_without_new_constant_marking'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:142:in `load'
    from /home/rsouthard/projects/inventory/vendor/rails/railties/lib/commands/servers/mongrel.rb:64
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/rsouthard/projects/inventory/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
    from /home/rsouthard/projects/inventory/vendor/rails/railties/lib/commands/server.rb:49
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/server:3

这是我的application.rb文件:

#added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  before_filters :authenticate

  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '4c5b23214f61143c4957b30c72169daf'

  # See ActionController::Base for details
  # Uncomment this to filter the contents of submitted sensitive data parameters
  # from your application log (in this case, all fields with names like "password").
  # filter_parameter_logging :password
  private
  def authenticate
    authenticate_or_request_with_http_basic do |username, password|
      username == "admin" && password == "h@x0rz"
    end
  end
end

1 个答案:

答案 0 :(得分:0)

问题在于before_filter行;我的第一个猜测是你应该尝试使用before_filter而不是before_filters(这是Rails 2.3.x中的正确函数,不确定它是否在那里被更改)我的下一个猜测是函数定义为您的项目中未定义authenticate_or_request_with_http_basic - 看起来您已将Lails冻结到项目中,因此您应该能够为def authenticate_or_request_with_http_basic grep整个项目树以查看它是否存在。