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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:56:40+00:00 2026-05-31T05:56:40+00:00

Imagine I have two models: foo and bar. I have a page where I

  • 0

Imagine I have two models:

foo and bar.

I have a page where I show X items (paginating with kaminari).

Those items would be a combination of foo and bar.

So I need to retrieve an array of X items ordered by created_at.

Imagine that foo have 25 items and bar just 10.

I ask for 10 items, and I need the first 10 items ordered by created_at. Maybe there are 7 foo and 3 bar mixed in.

I know that I can retrieve and merge them, but the problem is that if I request 10 foo and 10 bar, order by date and get the first 10. If I ask for page two, I will be losing items.

Maybe I’m asking too much, but would be good ask for a page 1, retrieve 10 items of foo/bar mix, ask for page 2, and same stuff. Maybe I need a third table?

Ideas? 🙂

  • 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-05-31T05:56:41+00:00Added an answer on May 31, 2026 at 5:56 am

    You could create a view that is the combination of the two tables. Then query for the top 10 records in that table. Check out this gem: https://rubygems.org/gems/rails_sql_views.

    If these are similar concepts, you could actually use one table and two models with single table inheritance.

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

Sidebar

Related Questions

Let's imagine we have two models: Teams: Id, Name Player: Id, Name, TeamId I
Imagine I have two models Film -name -description -duration -year_made -rating -actors Actor -name
Imagine you have two images A and B, and a third grayscale image T.
Imagine the following situation: I have two branches: DEV and MAIN. I'm working on
Imagine a situation, I have PC with two lan cards, one is connected to
I currently have two models: Campaigns and Videos. Videos belongs to Campaigns and a
I've got two models: Item and Tag . Both have a name attribute. I
Imagine I have two (three, four, whatever) tasks that have to run in parallel.
So imagine you have the following two tables: CREATE movies ( id int, name
Hello (please excuse me for my ugly english :p), Imagine these two simple models

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.