繁体   English   中英

阻止错误学习红宝石

[英]block error learning ruby on rails

我正在自学Ruby on Rails,我已经掌握了运行本地Web服务器的教程。 我已经完成了这一步的所有操作,当我运行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'

这是捆扎机抱怨缺少块。 我猜你的Gemfile搞砸了。 也就是说,你有这样的东西

group :development

而您应该提供一个街区

group :development do
  gem 'pry'
  # other gems
end

更新:

您的Gemfile中有几个错误

gem 'sqlite3',

这不应该有逗号

group =>assets do

这应该是group :assets do

组=>资产

您在gemfile中缺少冒号。 应该读:

组:资产

使用块时将发生此错误。

当您在方法内部使用了'yield'语句并且未将block作为参数传递时,它将引发'no block给出(yield)(LocalJumpError)'错误。

    def my_method
    yield
    end

puts my_method

在上面的方法调用中,我们没有将参数作为块传递,因此它将引发“(LocalJumpError)错误”。

这是将block作为参数传递的正确方法

def my_method
yield
end

puts my_method{puts 'something'}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM