RubyMine控制台:强制Ruby / Rails中止未命中类型语句的执行

时间:2012-08-14 09:41:20

标签: ruby-on-rails ruby rubymine

我在RubyMine的rails控制台中工作了很多,并且对以下情况感到非常沮丧:

>> User.find_by_name("Joe).id   
# Oh no, I forgot the closing double quote marks
# I'll try and cause an exception
>> "
>> ""
>> end
>> exit
# Well this is frustrating...
>> Foo
>> Bar
# rage quit

控制台不断等待,我想做的就是打破我的表情。我必须最终关闭控制台(或完全RubyMine)并重新启动它。

还有更好的解决方法吗?

3 个答案:

答案 0 :(得分:1)

在这种特殊情况下,按Ctrl+d,然后键入括号)应该:

1.9.3p194 :004 > Team.find_by_name("equipo1).id
1.9.3p194 :005"> cannot get out of here"
1.9.3p194 :006?>   hold on...
1.9.3p194 :007 >     ^D
1.9.3p194 :007?>   )
SyntaxError: (irb):6: syntax error, unexpected tIDENTIFIER, expecting ')'
hold on...
    ^
(irb):7: syntax error, unexpected ')'
    from /Users/dgarcia/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
    from /Users/dgarcia/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
    from /Users/dgarcia/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.3p194 :008 > puts "hooray!!"
hooray!!
 => nil 
1.9.3p194 :009 >

答案 1 :(得分:0)

按ctrl c即可退出此模式。

irb(main):265:0* "hello
irb(main):266:0"
irb(main):267:0"
irb(main):268:0"
irb(main):269:0" ^C
irb(main):269:0>

答案 2 :(得分:0)

用RubyMine 6.0 来解决这个问题。

使用CTRL + SHIFT + C