I am trying to do the following in a sinatra route:
get '/posts/:id' do
Post.find(params[:id]).to_json
end
But this is returning an enumerator.
How do I access a single object in json format?
PS I'm using datamapper
EDIT
I managed to return the json value by using get instead of find:
get '/posts/:id' do
Post.get(params[:id]).to_json
end
If someone can explain why I will accept answer so not to waste the question :)