FYI!

My good friend Robert (http://www.robertsosinski.com/) responded with
this excellent overview with which I got things running in about 20
lines of code:

####################################################

Hey Jeff,

You are dipping into one of the most interesting facets of REST, and
that is what constitutes REST in terms of routing is up to heated
debate.  The REST that you are used to using with resource routing is
really just the way that Rails has decided to use.  At the end of the
day, with REST the URL should just determine a resource, how it is
formatted can be a bit dicy.

Although OSM uses Rails, their routes are quite a bit off from normal
Rails resource routes.  This may be for a slew of reasons, one of
which there being quite a few devs who have felt the short comings of
terse http verb driven routes.  Active Resource works pretty well when
consuming from a textbook Rails RESTful API, however starts to become
very constricting once there is a deviation from it.  Also, Active
Resource is honestly still a bit buggy, and I would not count on OSM's
xml to not be mal-formed (my experience is that API's that are not
consumed by the developers themselves are often lacking in maturity).
This combination can make automagic Resource driven models
problematic.  One such example is running a Array#collect! method on a
Hash, which is what Active Resource is doing for you, and thus
yielding an error.

The solution, well is to write your own wrapper.  Thankfully this is
pretty easy.  I have had alot of success working with something called
HTTParty (http://railstips.org/2008/7/29/it-s-an-httparty-and-everyone-
is-invited) on github (http://github.com/jnunemaker/httparty).
HTTParty is basically a gem that gives you an easy to use interface to
Ruby's HTTP object that is very API centric.  The cool thing, is that
the API does not expect Rails RESTful routes and you can specify how
routes are interfaced with in a very granular way while HTTParty
handles the parsing of xml/json input and redundant domain interface
issues behind the scenes.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to