Note that there are some explanatory texts on larger screens.

plurals
  1. POdebugging activeresource
    text
    copied!<p>I'm trying to get activeresource (on Rails 3.2) working with the Freebase API and I haven't had much luck yet. How can I debug rails to see what's going on and make sure the request is well formed?</p> <p>I think the suffixed .json is causing the failure but I don't know how to check what's going on?</p> <p>Error:</p> <pre><code>ActiveResource::ResourceNotFound: Failed. Response code = 404. Response message = Not Found. </code></pre> <p>Code:</p> <pre><code>class Freebase &lt; ActiveResource::Base class &lt;&lt; self # also tried without this, same result def element_path(id, prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? "#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}" end def collection_path(prefix_options = {}, query_options = nil) prefix_options, query_options = split_options(prefix_options) if query_options.nil? "#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}" end end self.site = "https://www.googleapis.com/freebase/v1/" self.format = :json #https://www.googleapis.com/freebase/v1/search?query=nirvana&amp;indent=true #Freebase.get('search', :query =&gt; 'nirvana') end </code></pre> <p>UPDATE:</p> <p>Ok so I found two things going wrong...</p> <p>1) The collection_path I'm trying to supersede doesn't work at all.. it still tacks .json onto every request. 2) <code>https://www.googleapis.com:443/freebase/v1/freebases/search.json?query=nirvana</code> It tacks freebase on afterwards... any ideas?</p> <p>I also tried this fix:</p> <p><a href="https://stackoverflow.com/questions/3301086/remove-xml-extension-from-activeresource-request">Remove .xml extension from ActiveResource request</a></p> <p>But it didn't remove the JSON suffix either.</p> <p>UPDATE UPDATE:</p> <p>Added the suggest update below which gives the correct PATH but now I'm getting </p> <pre><code>GET https://www.googleapis.com:443/freebase/v1/search/?query=monkey --&gt; 200 OK 2732 (693.3ms) NoMethodError: undefined method `collect!' for #&lt;Hash:0x007f9bde674900&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload