Question

I have a RESTful API call that acts like this:

HTTP GET http://addresss:port/settings/{setting}

which returns just the value of the setting specified as a simple string:

"settingValue"

I want to retrieve this value using a subclass of ActiveResource:Base

class Settings < ActiveResource:Base
  self.site = CONFIG['uri']
  self.collection_name = 'settings'
  self.format = :json
  ...
end

But when I call Settings.find("Setting"), I get unexpected token at '"settingValue"'.

I could change the format of the data returned from the API, but is there anyway to get Rails to correctly handle this data?

Was it helpful?

Solution

Your api doesn't render json so Active Resource fails when it tries to parse a mere text.

Use another means to communicate with apis like restclient

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top