1

我的 Rails 环境遇到了一些问题 - 运行如下命令:

$ rails generate scaffold_controller model_name

导致以下跟踪:

/Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/generated_attribute.rb:13:in `parse': undefined method `split' for :clear:Symbol (NoMethodError)
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/named_base.rb:161:in `block in parse_attributes!'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/named_base.rb:160:in `map'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/named_base.rb:160:in `parse_attributes!'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/named_base.rb:21:in `initialize'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators/resource_helpers.rb:18:in `initialize'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/thor-0.18.1/lib/thor/group.rb:227:in `new'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/thor-0.18.1/lib/thor/group.rb:227:in `dispatch'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/generators.rb:171:in `invoke'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/commands/generate.rb:12:in `<top (required)>'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/me/.rvm/gems/ruby-1.9.3-p392@myproject/gems/railties-3.2.13/lib/rails/commands.rb:29:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

由于跟踪中的任何内容似乎都来自我的特定项目,因此我对可能发生的事情感到有些困惑。如您所见,我在 rvm 安装的 ruby​​ 1.9.3 上运行 rails 3.2.13。

有任何想法吗?

4

1 回答 1

0

我有同样的问题。事实证明,我的代码中某处有以下行。

include Term::ANSIColor

彩色术语输出需要此代码。但是当你需要生成或销毁脚手架时,可以暂时注释掉它。方法或符号 'clear' 与其他 gem 冲突。所以这可能也修复了 rake:erd。

于 2014-11-27T09:34:22.113 回答