Ruby on Rails - Lynda - 生成控制器和视图,错误生成' Rails生成'命令

时间:2014-07-01 18:18:00

标签: ruby-on-rails ruby command

我是Ruby on Rails的新手,并且正在关注Lynda的Ruby on Rails基本培训指南视频。

在入门视频集中,我们将展示“轨道生成器”的制作方法。命令有效。我已按照所有步骤操作,但每次输入' $ rails generate'我收到以下错误:

Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
    from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:33:in `<module:Spring>'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:4:in `<top (required)>'
    from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
    from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

你觉得我怎么解决这个问题?

3 个答案:

答案 0 :(得分:5)

答案在错误中:

You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all`

更新:

gem install rubygems-update

然后运行:

gem pristine --all

一切都应该好。

答案 1 :(得分:0)

我更新时

gem install rubygems-update

然后

 gem pristine --all

它对我没用。

但是来自How to upgrade rubygems的回答有助于修复问题,但在那之后由于某种原因我不得不再次安装rails并安装所有宝石。

安装rubygems-update

gem install rubygems-update
update_rubygems
gem update --system

以root身份运行此命令或使用sudo。

答案 2 :(得分:0)

我正在使用ruby和rbenv,所以我可以像普通用户那样运行它们。 但是,生成新的rails站点

rails new blog

显示有关旧rubygems的警告。

    Warning: You're using Rubygems 2.0.14 with Spring.

嗯。检查环境:

    gem env

显示

    RubyGems Environment:
      - RUBYGEMS VERSION: 2.0.14

这不好。正如我在互联网上建议的那样:

gem install rubygems-update
gem pristine --all
update_rubygems

我不确定宝石原始 - 是否需要,但它不会伤害任何东西。立即检查更新状态

    gem env

显示

    RubyGems Environment:
      - RUBYGEMS VERSION: 2.4.6

这很好。调用

rails new blog

一切都很顺利。完全没有警告。