I use HTTParty to consume a foreign API, but how can I convert the response into a Ruby class or Rails model?
+1
A:
It is going to depend on the output of your API. If the output is JSON, you can use the built-in Rails JSON parsing. If the output is XML in a Rails-friendly format, you may be able to use the built-in object-to-xml conversion tools. Otherwise, you may need to create your mapping explicitly.
Toby Hede
2010-01-26 22:29:52
A:
If the response is XML Nokogiri or ROXML come in handy. An alternative to ROXML would be Happymapper.
t6d
2010-01-26 22:43:36