rails生成脚手架失败红宝石1.9.3

时间:2014-10-20 03:55:50

标签: ruby ruby-on-rails-4

我只是在铁轨开发中弄湿了脚。试图学习#Tri; First First Rails",这已经过时了。但是我将命令更新为更现代版本的rails。

无论如何,我试图使用rails generate scaffold命令并遇到以下错误:

     [root@web1:/var/www/tickets] #rails generate scaffold name:string seat_id_seq:string address:text price_paid:decimal email_address:string
      invoke  active_record
/usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/base.rb:258:in `const_defined?': wrong constant name Name:string (NameError)
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/base.rb:258:in `block in class_collisions'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/base.rb:249:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/base.rb:249:in `class_collisions'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/named_base.rb:200:in `block in check_class_collision'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:277:in `block in _invoke_for_class_method'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/shell.rb:68:in `with_padding'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:266:in `_invoke_for_class_method'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:149:in `_invoke_from_option_orm'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators.rb:157:in `invoke'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands/generate.rb:11:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:135:in `generate_or_destroy'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:51:in `generate'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands.rb:17:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
        from /var/www/tickets/bin/rails:8:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `block in load'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
        from /usr/local/rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
        from -e:1:in `<main>'

我通过rvm运行ruby 1.9.3并通过gem运行rails 4。服务器是CentOS 7

我只是想知道你们中是否有人遇到类似的情况,并且知道如何克服这个错误。

谢谢!

1 个答案:

答案 0 :(得分:3)

Usage:
  rails generate scaffold NAME [field[:type][:index] field[:type][:index]] [options]

Examples:
    `rails generate scaffold post`
    `rails generate scaffold post title body:text published:boolean`

您没有指定名称属性,(即模型)