$ ./expense clear
This will remove all expenses. Are you sure? (y/n)
From: /Users/wangxuefei/Documents/launchschool/180/4/expense/expense @ line 51 ExpenseData#clear_expenses:
47: def clear_expenses
48: puts "This will remove all expenses. Are you sure? (y/n)"
49: answer = nil
50: loop do
=> 51: binding.pry
52: answer = gets.chomp.to_s.downcase
53: break if %(y n).include? answer
54: puts "You must press 'y' or 'n'."
55: end
56:
57: return if answer == 'n'
58:
59: sql = "DELETE FROM expenses;"
60: @connection.exec(sql)
61: puts "All expenses have been deleted."
62: end
[1] pry(#<ExpenseData>)> answer = gets.chomp.to_s.downcase
Errno::ENOENT: No such file or directory @ rb_sysopen - clear
from (pry):1:in `gets'
[2] pry(#<ExpenseData>)> require 'io/console'
=> false
刚开始学数据库
请教下各位朋友 这里为什么 gets 用不了啊,想用 getch, 可是 require 'io/console'又不好使。 但是在 irb 下,prompt 这个代码是能正常运行的
另外这个问题该用什么有效的英文关键字在 google 搜索答案呢?搞了半天也找到。