[英]block error learning ruby on rails
i am teaching myself Ruby on rails i have got up to the tutorial on running the local web server. 我正在自学Ruby on Rails,我已经掌握了运行本地Web服务器的教程。 i have done everything up to this step and when i run
rails server
i get this error can someone explain what is going on in this error. 我已经完成了这一步的所有操作,当我运行
rails server
此错误,有人可以解释该错误的原因。
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/d
sl.rb:159:in `group': no block given (yield) (LocalJumpError)
from C:/Users/rto/Desktop/rails_projects/first_app/Gemfile:23:in `eval_g
emfile'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler/dsl.rb:30:in `instance_eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler/dsl.rb:30:in `eval_gemfile'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler/dsl.rb:9:in `evaluate'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler/definition.rb:19:in `build'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler.rb:148:in `definition'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler.rb:116:in `setup'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/
lib/bundler/setup.rb:7:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:116:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:116:in `rescue in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:122:in `require'
from C:/Users/rto/Desktop/rails_projects/first_app/config/boot.rb:6:in `
<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:51:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/core_
ext/kernel_require.rb:51:in `require'
from script/rails:5:in `<main>'
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3',
# Gems used only for assets and not required
# in production environments by default.
group =>assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs
#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
This is bundler complaining about missing blocks. 这是捆扎机抱怨缺少块。 I'd guess that your Gemfile is messed up.
我猜你的Gemfile搞砸了。 That is, you have there something like this
也就是说,你有这样的东西
group :development
Whereas you are supposed to provide a block 而您应该提供一个街区
group :development do
gem 'pry'
# other gems
end
You have several errors in your Gemfile 您的Gemfile中有几个错误
gem 'sqlite3',
This shouldn't have a comma 这不应该有逗号
group =>assets do
This should be group :assets do
这应该是
group :assets do
group =>assets do
组=>资产
you are missing a colon in gemfile. 您在gemfile中缺少冒号。 Should read:
应该读:
group :assets do
组:资产
This error will occur when working with blocks. 使用块时将发生此错误。
When you used the 'yield' statement inside the method and didn't pass block as parameter then it will raise the 'no block given (yield) (LocalJumpError)' error. 当您在方法内部使用了'yield'语句并且未将block作为参数传递时,它将引发'no block给出(yield)(LocalJumpError)'错误。
def my_method
yield
end
puts my_method
In the above method call we are not passing parameter as a block so it will throw '(LocalJumpError) error'. 在上面的方法调用中,我们没有将参数作为块传递,因此它将引发“(LocalJumpError)错误”。
Here is the correct way to pass block as a parameter 这是将block作为参数传递的正确方法
def my_method
yield
end
puts my_method{puts 'something'}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.