Closed volkanunsal closed 13 years ago
Am I correct in assuming that you are trying to use array of hashes as the object? I don't see you specifying any output in the rabl file as to what attributes you want displayed either. Something like
#zip_lookup.json.rabl
collection @result => :places
attributes :quality, :latitude, :longitude
Also, RABL doesn't really work for simple hashes in this way. RABL was intended to be used with ORM records (AR, Mongoid) or in the git version any object that supports "dot" notation for attributes. A hash is not intended to work as an object but you could make it work anyways with RABL since its fairly flexible:
object false # skip objects (hash isn't supported as an object)
# create a "places" node
node :places do
# setup a { place : { ...data... } } json array
@result.map { |data| { :place => data } }
end
as an example.
My usecase is simple. I fetch a geocoded array of objects and render them as a json template. I tried using rabl for the first time today, and it returns empty arrays. Here is my code.
And the output is: