문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top