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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:59:42+00:00 2026-06-06T02:59:42+00:00

While trying to search with id sorting (and paginating) im getting from the log:

  • 0

While trying to search with id sorting (and paginating) im getting from the log:

SELECT `audits`.* FROM `audits` ORDER BY version, id DESC LIMIT 50 OFFSET 0

I am currently using this code:

@records = Audit.order("id DESC").page(page).per(50)

The problem is that the list retrieved is not correctly sorted by id descending.

BTW i am using audited-activerecord gem for audits, does this matter?

  • 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-06T02:59:44+00:00Added an answer on June 6, 2026 at 2:59 am

    I’m guessing that your gem is setting a default scope on the Audit model that orders by version, so at the moment it is ordering in ascending order by the version column, and, only if two records are the same, is it ordering by id in descending order.

    To fix this, you can prepend unscoped to your chain:

    Audit.unscoped.order("id DESC").page(page).per(50)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do a simple search query in php with: SELECT * FROM
I am trying to search/select a link in a page that is underlined, while
What i'm trying to do is search a textarea while the user is typing
I am trying to get the history and search results from the android browser.
While trying to retrieve the URL http://www.kat.ph/search/snow-patrol-shut-your-eyes/?categories%5B%5D=music using curl I am getting an error
I am trying to search if char from alpabet array is equal to the
While in search of trying to implement unique key validations for my db using
I'm trying to search two fields as one from a MySQL database using PHP.
While trying problem 41 from the Euler Project, I ran across what seems to
I got this error while trying to get facebook access_token from node.js server: {error:{message:(#803)

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.