Reputation: 100
I'm trying to use an API as a database for my rails application using ActiveRestClient
, but when I try to query from the API I get an ArgumentError: no time information in "0"
. I don't understand where the call to time.rb is coming from. Any ideas what causes the problem and how I can solve this problem?
Thanks in advance!
This is the code I'm using:
class Db < ActiveRestClient::Base
base_url "https://Placeholder/api/vtest/"
get :all, "/customer?apiKey=tester"
get :find, "/customer/:id?apiKey=tester"
before_request do |name, request|
request.headers["Accept"] = "application/json"
request.headers["User-Agent"] = "random"
end
end
And this is the error message I'm getting:
ArgumentError: no time information in "0"
from /home/wouter/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/time.rb:252:in `make_time'
from /home/wouter/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/time.rb:364:in `parse'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/active_rest_client-1.0.8/lib/active_rest_client/caching.rb:69:in `write_cached_response'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/active_rest_client-1.0.8/lib/active_rest_client/request.rb:162:in `block in call'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `block in instrument'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `instrument'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/active_rest_client-1.0.8/lib/active_rest_client/request.rb:116:in `call'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/active_rest_client-1.0.8/lib/active_rest_client/mapping.rb:46:in `_call'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/active_rest_client-1.0.8/lib/active_rest_client/mapping.rb:28:in `block in _map_call'
from (irb):1
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /home/wouter/projects/NavAds/Test/bin/rails:8:in `<top (required)>'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/wouter/.rvm/gems/ruby-2.2.2@global/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /home/wouter/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/wouter/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
Upvotes: 0
Views: 1465
Reputation: 1
It's really hard to say where the call comes from, only you can figure that out. This timeError happens when there is a call to Time.parse and there is an invalid input (in your case "0", looking at your error).
Have you tried going through the stack trace, since you are saying you don't know where the error is coming from. I'd recommend using the gem "better_errors", this way you can go through the stack trace and have an interactive console for every file. This is the way I solve bugs :). Good luck!
Upvotes: 0