Ruby on Rails生成器无法正常工作

时间:2015-03-23 13:21:31

标签: ruby-on-rails ruby ruby-on-rails-3

我有问题。 当我试图通过rails生成内容g / rails生成controller / model / etc时,我在终端中将此消息作为输出。 我做错了什么?

user@vps:/var/www/dap$ rails -v
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
Rails 4.2.0
user@vps:/var/www/dap$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
user@vps:/var/www/dap$ ruby script/generate controller StaticPages home help about ruby: No such file or directory -- script/generate (LoadError)
user@vps:/var/www/dap$ bin/rails generate controller StaticPages home help about
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
^C/var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/run.rb:99:in `gets': Interrupt
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/run.rb:99:in `verify_server_version'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/run.rb:56:in `run'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/run.rb:37:in `warm_run'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/run.rb:26:in `call'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/command.rb:7:in `call'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/rails.rb:23:in `call'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client/command.rb:7:in `call'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/client.rb:26:in `run'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/bin/spring:48:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/binstub.rb:11:in `load'
    from /var/lib/gems/1.9.1/gems/spring-1.3.3/lib/spring/binstub.rb:11:in `<top (required)>'
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /var/www/dap/bin/spring:13:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

P.S。只是在一个案例中添加了ruby和rails版本。

1 个答案:

答案 0 :(得分:1)

Rails 4.2要求ruby版本至少为1.9.3。喜欢2.0 +

请勿使用outdated版本。

另外,看起来你正在使用系统ruby。不要用它。坚持rbenvRVM