gpt4 book ai didi

ruby - rails 生成脚手架失败 ruby​​ 1.9.3

转载 作者:太空宇宙 更新时间:2023-11-03 18:15:44 25 4
gpt4 key购买 nike

我刚刚接触 Rails 开发。试图从相当过时的“Head 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

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

谢谢!

最佳答案

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`

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

关于ruby - rails 生成脚手架失败 ruby​​ 1.9.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26458372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com