您好我在生成模型时遇到错误。在我面对的错误堆栈之后。
rails generate model id:string name:string userid:string groupid:string bookmarktype:string typeid:string additionaldata:string
include_class is deprecated. Use java_import.
include_class is deprecated. Use java_import.
Resolved collector.newrelic.com to 204.93.223.153
invoke active_record
NameError: wrong constant name Id:string
const_defined? at org/jruby/RubyModule.java:2608
class_collisions at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/railties-3.2.3/lib/rails/generators/base.rb:267
each at org/jruby/RubyArray.java:1612
class_collisions at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/railties-3.2.3/lib/rails/generators/base.rb:249
check_class_collision at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/railties-3.2.3/lib/rails/generators/named_base.rb:183
__send__ at org/jruby/RubyBasicObject.java:1667
send at org/jruby/RubyKernel.java:2060
run at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/task.rb:21
invoke_task at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/invocation.rb:118
invoke_all at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/invocation.rb:124
each at org/jruby/RubyHash.java:1192
map at org/jruby/RubyEnumerable.java:715
invoke_all at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/invocation.rb:124
dispatch at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/group.rb:226
__send__ at org/jruby/RubyBasicObject.java:1694
send at org/jruby/RubyKernel.java:2072
invoke at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/invocation.rb:109
_invoke_for_class_method at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/group.rb:269
with_padding at /home/anand/.rvm/gems/jruby-1.7.0.preview2/gems/thor-0.14.6/lib/thor/shell.rb:74
以下是rvm list的输出
rvm list
rvm rubies
=* jruby-1.7.0.preview2 [ i386 ]
ruby-1.9.3-p194 [ i686 ]
# => - current
# =* - current && default
# * - default
我正在使用Ubuntu 12.04。如何解决这个问题?
答案 0 :(得分:1)
您需要在使用字段生成时提供模型名称。例如,
rails generate model UserDetails id:string name:string userid:string groupid:string bookmarktype:string typeid:string additionaldata:string
'UserDetails'是型号名称。
这可能是问题所在。不确定你要问的是什么。干杯!