无论我发出rake,rails等命令,我在rails应用程序中都会遇到同样的错误。
Block not supplied (ArgumentError)
C:\Sites\merevik\merevik>rails console
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/ra
iltie/configurable.rb:24:in `class_eval': block not supplied (ArgumentError)
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/railtie/configurable.rb:24:in `configure'
from C:/Sites/merevik/merevik/config/initializers/setup_mail.rb:2:in `bl
ock in <top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/railtie/configurable.rb:24:in `class_eval'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/railtie/configurable.rb:24:in `configure'
from C:/Sites/merevik/merevik/config/initializers/setup_mail.rb:1:in `<t
op (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:245:in `load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:245:in `block in load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:245:in `load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/engine.rb:587:in `each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/engine.rb:587:in `block in <class:Engine>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/initializable.rb:30:in `instance_exec'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/initializable.rb:30:in `run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/initializable.rb:54:in `each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/initializable.rb:54:in `run_initializers'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/application.rb:136:in `initialize!'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/railtie/configurable.rb:30:in `method_missing'
from C:/Sites/merevik/merevik/config/environment.rb:5:in `<top (required
)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:251:in `require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/activesupport-
3.2.1/lib/active_support/dependencies.rb:251:in `require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/application.rb:103:in `require_environment!'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.2.1
/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
答案 0 :(得分:1)
您似乎是在configure
的第2行调用setup_mail.rb
而未传递阻止。在第1行,你也在调用configure
,并在第2行传递包含错误调用的块。我猜你正在做类似的事情:
configure.some_option = 'value'
你真正想要的地方:
config.some_option = 'value'
这是configure
的来源:
def configure(&block)
class_eval(&block)
end
在没有阻止的情况下调用class_eval
将始终抛出ArgumentError
。