0

我正在自学 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'
4

3 回答 3

1

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

group :development

而你应该提供一个块

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

更新:

您的 Gemfile 中有几个错误

gem 'sqlite3',

这不应该有逗号

group =>assets do

这应该是group :assets do

于 2013-07-15T09:59:03.740 回答
1

组=>资产做

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

组:资产做

于 2013-10-30T08:03:00.537 回答
-2

使用块时会发生此错误。

当您在方法中使用“yield”语句并且没有将块作为参数传递时,它将引发“没有给定块(yield)(LocalJumpError)”错误。

    def my_method
    yield
    end

puts my_method

在上面的方法调用中,我们没有将参数作为块传递,所以它会抛出“(LocalJumpError)错误”。

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

def my_method
yield
end

puts my_method{puts 'something'}
于 2013-07-15T09:54:48.397 回答