当我将多行指令粘贴到其中时,Rails控制台启动“显示所有573种可能性?(y或n)”对话框

时间:2013-08-08 22:01:40

标签: ruby-on-rails

我正在将以下代码段从我的文本编辑器复制到我的rails控制台:

request = Typhoeus::Request.new(
"https://track.customer.io/api/v1/customers/4", 
ssl_verifypeer: false,
method: :put,
headers: {
    "Content-Type" => "application/json",
    "User-Agent" => "#{Rails.configuration.customerio[:site_id]}:#{Rails.configuration.customerio[:api_key]}"},
body: '{
"email":"first@last.com", 
"name":"Name is here",
"id":"4",
"created_at":"#{Time.now}"}')

当我将它全部复制为一行时:

request = Typhoeus::Request.new("https://track.customer.io/api/v1/customers/4", ssl_verifypeer: false,method: :put,headers: {"Content-Type" => "application/json","User-Agent" => "#{Rails.configuration.customerio[:site_id]}:#{Rails.configuration.customerio[:api_key]}"},body: '{"email":"first@last.com", "name":"Name is here","id":"4","created_at":"#{Time.now}"}')

然后控制台返回标准响应:

 => #<Typhoeus::Request:0x00000101c517a8 @base_url="https://track.customer.io/api/v1/customers/4", @original_options=...

但是,如果我逐行复制(就像我在第一个代码片段中所做的那样),我会收到一个奇怪的错误。控制台询问我是否要显示所有可能性,就像我正在搜索目录或在粘贴中途进行搜索查询一样。看看:

1.9.3p393 :091 > request = Typhoeus::Request.new(
1.9.3p393 :092 >     "https://track.customer.io/api/v1/customers/4", 
1.9.3p393 :093 >     ssl_verifypeer: false,
1.9.3p393 :094 >     method: :put,
1.9.3p393 :095 >     headers: {
1.9.3p393 :096 >
Display all 573 possibilities? (y or n) 
1.9.3p393 :096 >       "Content-Type" => "application/json",
1.9.3p393 :097 >
Display all 573 possibilities? (y or n) 
1.9.3p393 :097 >       "User-Agent" => "#{Rails.configuration.customerio[:site_id]}:#{Rails.configuration.customerio[:api_key]}"},
1.9.3p393 :098 >     body: '{
1.9.3p393 :099'> "email":"first@last.com", 
1.9.3p393 :100'> "name":"Name is here",
1.9.3p393 :101'> "id":"4",
1.9.3p393 :102'> "created_at":"#{Time.now}"}')

如果我同时选择n,则会正常创建请求。但是,如果我选择y,则会列出573项,其中大部分都是我放入这个贴纸的:http://pastie.org/private/ksgzqhd50mvdi0t6cqe8g

你知道这些结果是什么吗,更重要的是,为什么他们会在这个奇怪的时间被提示?

1 个答案:

答案 0 :(得分:7)

听起来你复制代码的来源有两个制表符,其中"Content-Type"..."User-Agent"...是缩进的。两个制表符将调用控制台中的自动完成列表(您看到的提示是当可能的完成次数超过某个阈值时)。

请注意,如果您从自己的StackOverflow帖子中复制并粘贴它,则不应该看到自动完成提示,因为它使用空格来缩进而不是制表符。

编辑:

要确认我的怀疑,请在编辑器中打开“显示空白”,看看这两行的开头是否有制表符。

个人意见:如果您还没有这样做,我建议您将编辑器配置为为Tab键按下插入空格。标签是魔鬼的空白:)。

相关问题