rails generate scaffold用户名:string email:string

时间:2015-08-10 22:08:43

标签: ruby-on-rails ruby string scaffold

虽然在第2.2节中做了https://www.railstutorial.org/book/toy_app教程,我必须写一下$ rails generate scaffold User name:string email:string,但我遇到了一些错误:

c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `require': cannot load such file -- pty (LoadError)
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web_console/slave.rb:1:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web_console.rb:13:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/web-console-2.0.0.beta3/lib/web-console.rb:1:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
        from c:/Users/User/desktop/web/workspace/toy_app/config/application.rb:7:in `<top (required)>'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:141:in `require'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:141:in `require_application_and_environment!'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:128:in `generate_or_destroy'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:50:in `generate'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

有什么建议吗?这一直困扰着我

1 个答案:

答案 0 :(得分:1)

问题是Rails 4.2.0beta及更高版本依赖于pty gem并且无法找到它。

`require': cannot load such file -- pty (LoadError)

这是因为Windows上尚未提供此gem。对于临时修复,您可以从web-console删除Gemfile gem并在删除该gem后运行bundle install