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 8839521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:15:19+00:00 2026-06-14T10:15:19+00:00

I have this http://localhost:3000/api/products request that returns json format output with a list of

  • 0

I have this http://localhost:3000/api/products request that returns json format output with a list of products objects. I heard in some scenario its better to use multi-gets design where you list products ids in URI like so http://localhost:3000/api/products?ids=1,2,3,4. My question is how do i configure the route to return such an URI? Below is the json output returned by http://localhost:3000/api/products.Thank you in advance

controller

def index
@products=Product.all

respond_to do |format|
  format.json { render json: @products.to_json}
  format.xml
end
end

json output
[

{
    "category_id": null,
    "created_at": "2011-03-25T13:35:16Z",
    "details": "Molestias pariatur consequuntur ut voluptas aperiam facere et et autem ad laudantium ut qui dolorem iste sit ut in dignissimos. Et debitis et et sunt quidem qui est est et numquam in dolorum natus sapiente nihil ipsa ratione. Quisquam aut molestiae earum voluptas vero et officiis magnam quam provident voluptatibus quia",
    "id": 1,
    "product_name": "Velit",
    "publisher_id": 1,
    "updated_at": "2012-11-12T18:45:13Z",
    "publisher_details": "http://localhost:3000/api/users/1"
},
{
    "category_id": null,
    "created_at": "2012-01-10T23:16:53Z",
    "details": "Temporibus quis et quam eveniet hic consequatur maiores eum expedita molestiae velit eligendi laboriosam ut molestiae. Velit delectus aliquid nobis quia velit aut dolorem omnis numquam reprehenderit quo illo saepe molestiae nisi. Soluta nihil quae soluta facilis cumque voluptates eaque amet unde non in placeat id cupiditate illum at et vero. Laborum id eaque voluptas illo eius iure",
    "id": 2,
    "product_name": "Nam Laboriosam Et Sed",
    "publisher_id": 1,
    "updated_at": "2012-11-12T18:45:13Z",
    "publisher_details": "http://localhost:3000/api/users/1"
}]
  • 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-14T10:15:20+00:00Added an answer on June 14, 2026 at 10:15 am

    There is a gem, which is discontinued, which was written for sproutcore (now ember) that offered this out of the box: https://github.com/drogus/bulk_api

    But actually, it does not have to be that hard at all. For a single controller I would just do something like

     def index
       ids = params[:ids]
       if ids.blank?
         @categories = Category.all
       else  
         wanted_ids = ids.split(',')
         @categories = Categoriy.where(:id => wanted_ids)
       end
       render :json => @categories
     end
    

    Does that help?

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

Sidebar

Related Questions

request.url returns me this : http://localhost:3000/page?foo=bar . Is there a method I can call
I have a URL like this for each record: http://localhost:3000/items/3/stuff.json http://localhost:3000/items/1/stuff.json http://localhost:3000/items/4/stuff.json http://localhost:3000/items/9/stuff.json when
I have this if( window.location.href == http://localhost:3000/categories) { $(#container ul #all_categories a.categories-menu).css(font-weight,bold); } });
I have this: <li><%= link_to More, feed_products_path(product.id) ,{:class=>button-small white} %></li> This link outputs: http://localhost:3000/feed_products.34
I have write a api service at 'http://localhost:3000/api/user/id', do a GET, can get a
I have this search controller url: http://localhost:3000/search/index?utf8=✓&search=Search_terms how can trim this to: http://localhost:3000/search=query the
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have strings like this: http://localhost:2055/web-site-2009/paginas/noticias/**IGP-M recua 0,36% em agosto, aponta FGV**-46.aspx I'd like
I have URL like this: http://localhost/PMApp/temp.htm?ProjectID=462 What I need to do is to get
I have this model var Item = Backbone.Model.extend({ url: 'http://localhost/InterprisePOS/Product/loaditembycategory/Event Materials' }); var onSuccess

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.