开发者

Exiting the Rails console after an error

I have been use the rails console for testing and learning purposes and when I encounter an error I cannot exit anymore using the "Control + C" command. Is there another command to exit? This is what the console looks like when I try to do this:

ruby-1.9.2-p180 :026 > user.find_by_name("Test")
NoMethodError: undefined method `find_by_name' for #<User:0x00000100f991a0>
    from /Users/easierlife/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activemodel-3.0.7/lib/active_model/attribute_methods.rb:367:in `method_missing'
    from /Users/easierlife/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/activerecord-3.0.7/lib/active_record/attribute_methods.rb:46:in `method_missing'
    from (irb):26
    from /Users/easierlife/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
    from /Users/easierlife/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
    from /Users/easierlife/.rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rai开发者_如何转开发ls:6:in `require'
    from script/rails:6:in `<main>'
ruby-1.9.2-p180 :027 > ^C^C^C^C^C

Thanks


You could try:

  • Ctrl D
  • Ctrl Z and then Enter
  • Typing exit, then Enter.


if the above fails, open another terminal then:

ps aux | grep ruby

you'll get something like:

username      917  52.7  0.4  2455912  17484 s000  R+    9:22AM   0:01.13 /Users/yourusername/.rvm/rubies/ruby-1.9.2-p180/bin/ruby script/rails c

you'll need the "917" id:

sudo kill -9 917

(also i think this should be migrated to superuser.com)


You can come out from console screen by simply typing 'exit' on console and pressing 'enter'.

but today i faced some weird issue, when i displayed all records available in table which exceeds console screen size

then i pressed enter button until we reach end of records, now if we press "Control + C", "Control + Z" and exit commands nothing worked for me.

I get stuck on console screen and screen was not allowing me to do anything.

Finally got Solution!!!!

press 'q' key 

BooM!!

Now every thing normal :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜