Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:48:04+00:00 2026-06-05T06:48:04+00:00

I am trying to do the following in a sinatra route: get ‘/posts/:id’ do

  • 0

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 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:48:05+00:00Added an answer on June 5, 2026 at 6:48 am

    find doesn’t exist in DataMapper. It’s a method of Ruby’s Enumerable, that returns an enumerator object ; which you’re trying to convert to JSON.

    DataMapper objects apparently implement Enumerable, that’s why you don’t get an undefined method exception.

    Enumerable#find: http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-find

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get contents of NSMutableDictionary into NSMutable array? I am trying following but
I'm trying to deploy a Sinatra app to Dreamhost and it says the following:
I am trying following, 1. Get response using Ajax from the users selection which
I am trying the following query and get only zero results (I am supposed
I am trying the following piece of code in java, but it doesn't seem
I'm trying the following and cannot find out what is wrong: IF( IFNULL( SELECT
I'm trying to get a sinatra app as a subpath in my rails 3
I am trying to get a loop for following... {$product.min_val} //2 {$product.max_val} //8 and
I've been trying the following to get the textview to update on any changes
I've been trying to get a simple hello world web app running on Sinatra.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.