I've looked at this question but it's quite old and I feel there's now other alternatives to ARes.

Given that many people seem to think that ActiveResource is kind of outdated and heavyweight, I've looked at Api Smith, Her, Roar and of course ARes.

Which one of these gems would be the most reliable, and future proof alternative?

有帮助吗?

解决方案

Why not using lower level libraries like HTTParty or Faraday ? They will cover a lot of the ugly stuff for you (ssl, parsing/serializing jsons and XMLs, logging, adding headers...) and you'll keep complete control of the URLs and the management of data.

其他提示

I found that simply using open-uri and json is a viable option. Less boilerplate and more control / configurability.

Example:

@people = JSON.parse(open("http://api.people.com:3000/people").read, symbolize_names: true)

Roar gem's purpose is to help you build and deserialize objects and it handles a several different JSON formats like JSON-API, JSON-HAL, etc, XML and it's fairly easy to extend the underlying Representable Gem ( forked from popular ROXML gem). Considering Roar is by far the most popular alternative to ARes, and is part of the much larger Trailblazer Ecosystem ( thou you can use it on it's own) - I would argue Roar is more "future proof". But I might be biased.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top