簡體   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