I am copying the following snippet from my text-editor to my rails console:
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":"[email protected]",
"name":"Name is here",
"id":"4",
"created_at":"#{Time.now}"}')
When I copy it all as one line:
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":"[email protected]", "name":"Name is here","id":"4","created_at":"#{Time.now}"}')
Then console returns with a standard response:
=> #<Typhoeus::Request:0x00000101c517a8 @base_url="https://track.customer.io/api/v1/customers/4", @original_options=...
However, if I copy it line-by-line (as I did in the first code snippet) I get a strange error. The console asks me if I want to display all possibilities, as if I'm searching a directory or making a search query midway through the paste. Check it out:
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":"[email protected]",
1.9.3p393 :100'> "name":"Name is here",
1.9.3p393 :101'> "id":"4",
1.9.3p393 :102'> "created_at":"#{Time.now}"}')
If I select n
both times, the request is created normally. However, if I select y
, it lists 573 items, most of which I've put into this pastie: http://pastie.org/private/ksgzqhd50mvdi0t6cqe8g
Do you know what these results are and, more importantly, why they're being prompted at this strange time?
Sounds like the source you're copying the code from has two tab characters where "Content-Type"...
and "User-Agent"...
are indented. Two tab characters will invoke the auto-completion list in the console (the prompt you're seeing is when the number of possible completions exceeds a certain threshold).
Notice that if you copy and paste it from your own StackOverflow post you shouldn't see the auto-complete prompts because it is using spaces for the indentation and not tabs.
Edit:
To confirm my suspicion, turn on "show whitespace" in your editor to see if there are tab characters at the start of those two lines.
Personal opinion: I would recommend that you configure your editor to insert spaces for tab key presses if you haven't already done so. Tabs are the devil's whitespace :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With