2015-05-04 50 views
0

我試圖使用API​​作爲我的rails應用程序的數據庫使用ActiveRestClient,但是當我嘗試從API查詢時,我得到一個ArgumentError: no time information in "0" 。我不明白time.rb的調用來自何處。任何想法是什麼導致這個問題,我怎麼能解決這個問題?ArgumentError:沒有時間信息在「0」使用ActiveRestClient in rails 4.2.1

提前致謝!

這是我使用的代碼:

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 

這是錯誤消息我得到:

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/[email protected]/gems/active_rest_client-1.0.8/lib/active_rest_client/caching.rb:69:in `write_cached_response' 
    from /home/wouter/.rvm/gems/[email protected]/gems/active_rest_client-1.0.8/lib/active_rest_client/request.rb:162:in `block in call' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `block in instrument' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in `instrument' 
    from /home/wouter/.rvm/gems/[email protected]/gems/active_rest_client-1.0.8/lib/active_rest_client/request.rb:116:in `call' 
    from /home/wouter/.rvm/gems/[email protected]/gems/active_rest_client-1.0.8/lib/active_rest_client/mapping.rb:46:in `_call' 
    from /home/wouter/.rvm/gems/[email protected]/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/[email protected]/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start' 
    from /home/wouter/.rvm/gems/[email protected]/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start' 
    from /home/wouter/.rvm/gems/[email protected]/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console' 
    from /home/wouter/.rvm/gems/[email protected]/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
    from /home/wouter/.rvm/gems/[email protected]/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/wouter/.rvm/gems/[email protected]/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/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load' 
    from /home/wouter/.rvm/gems/[email protected]/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency' 
    from /home/wouter/.rvm/gems/[email protected]/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' 

回答

0

這真的很難說,那裏電話從哪裏來,只你可以弄清楚。這個時間錯誤發生在有Time.parse的調用時,並且有一個無效的輸入(在你的情況下爲「0」,看着你的錯誤)。

您是否嘗試過通過堆棧跟蹤,因爲您說您不知道錯誤來自哪裏。我建議使用gem「better_errors」,這樣你可以通過堆棧跟蹤併爲每個文件設置一個交互式控制檯。這是我解決bug的方式:)。祝你好運!

+0

它不能被歸類爲答案。 –

+0

如何回答沒有文件? – Abel

相關問題