简体   繁体   中英

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. 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.

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. 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

Update:

You have several errors in your Gemfile

gem 'sqlite3',

This shouldn't have a comma

group =>assets do

This should be group :assets do

group =>assets do

you are missing a colon in 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.

    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'.

Here is the correct way to pass block as a parameter

def my_method
yield
end

puts my_method{puts 'something'}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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