为什么在使用选项运行rails generate时,minitest抛出OptionParse :: InvalidOption?

时间:2011-12-27 21:57:04

标签: ruby-on-rails rvm minitest

每当使用一个或多个选项运行Rails生成器时,最薄的引发OptionParse::InvalidOption

我正在使用Rails 3.1,Ruby 1.9.2-p290和Mintest 2.10.0。

generate命令实际上会运行并处理传递的选项,但Minitest会在最后引发异常和堆栈跟踪:

rails generate model x --no-migration -s -p

  invoke  active_record     
  identical    app/models/x.rb 
  invoke test_unit 
  identical      test/unit/x_test.rb 
  identical     test/fixtures/xs.yml

  /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:900:in 'block in process_args': invalid option: --no-migration (OptionParser::InvalidOption)       
  from /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:879:in 'new'
  from /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:879:in 'process_args'
  from /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:929:in '_run'
  from /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:922:in 'run'  
  from /Users/max/.rvm/gems/ruby-1.9.2-p290/gems/minitest-2.10.0/lib/minitest/unit.rb:690:in 'block in autorun'

还有其他人遇到过这个吗?

1 个答案:

答案 0 :(得分:0)

正如日志中所述 - 没有这样的选项--no-migration(根据我的理解应该可用),这就是你抛出错误的原因。试试--skip-migration