问题描述
|
有人收到过这个红宝石警告吗?警告:冗余嵌套重复操作符
这是什么意思?
启动Webrick时了解
这是我的踪迹的样子:
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/strexp.rb:4
1: warning: redundant nested repeat operator
c:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.0.5/lib/action_dispatch/routing
/route.rb:25: warning: redundant nested repeat operator
c:/Ruby192/lib/ruby/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/route.rb:46
我正在使用Rails 3.0.5和Ruby 1.9.2 p180
解决方法
当您在单个原子上具有两个重复运算符的正则表达式时,就会发生这种情况。例如。,
ruby-1.9.2-p180 :001 > re = /\\w**/
~/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80:
warning: redundant nested repeat operator: /\\w**/
=> /\\w**/
鉴于回溯路线看起来像路由库(我个人没有使用过机架安装的gem),我想您的一条路线要么包含冗余的重复运算符,要么被简化为正则表达式有一个。
,@michael的回应让我发现了真正的问题:
如果您的routes.rb中包含以下内容,
match \"/foo(/bar(/something)))\" => \"controller#action\"
您会收到上述警告。存在警告您/foo
有效,/foo/bar
也有效,/foo/bar/something
也有效