每当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'
Run Code Online (Sandbox Code Playgroud)
还有其他人遇到过这个吗?
我正在构建一个iPhone应用程序.我有一个UIView包含一组UIImageView子类对象.用户可以通过触摸拖动和旋转图像视图.旋转后我无法移动图像视图.
要旋转图像视图,我应用变换旋转,这很好.它看起来像这样:
CGAffineTransform trans = self.transform;
self.transform = CGAffineTransformRotate(trans, delta);
Run Code Online (Sandbox Code Playgroud)
当用户尝试通过触摸移动元素时,问题就出现了.在touchesBegan:WithEvent:中,我将起始点保存在类变量startLocation中:
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
// Retrieve the touch point
CGPoint pt = [[touches anyObject] locationInView:self];
startLocation = pt;
}
Run Code Online (Sandbox Code Playgroud)
在touchesMoved:withEvent:中,我有以下代码,如果图像视图上没有旋转变换,它的效果很好:
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject] locationInView:self];
CGFloat dx = pt.x - startLocation.x;
CGFloat dy = pt.y - startLocation.y;
CGPoint newCenter = CGPointMake(self.center.x + dx, self.center.y + dy);
self.center = newCenter;
}
Run Code Online (Sandbox Code Playgroud)
但是如果在图像视图上存在旋转变换,则图像视图会在每个touchesMoved事件上的屏幕上晃动并很快消失.在调试器中,我观察到pt的值变得怪异.在我看来,我需要改变这一点,我做了,就像这样:
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject] locationInView:self]; …Run Code Online (Sandbox Code Playgroud)