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

The Archive Base Latest Questions

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

I am doing some maintenance on a Rails 2 application using Ruby 1.8.7. I

  • 0

I am doing some maintenance on a Rails 2 application using Ruby 1.8.7. I am using will_paginate.

I have the following problem:
When calling current_user.products.paginate(:page => 1, :order => “updated_at asc“) it orders, as expected, based on the updated_at property in products.

However, when calling current_user.products.paginate(:page => 1, :order => “released_at asc“) it does not order on released_at as expected. In fact it doesn’t matter whether I specify ordering to happen according to “asc” or “desc”, I get the same collection returned.

updated_at and released_at are both attributes defined on the model and exists in the database and all values are non-null. There is no default_scope defined on the models.

What could be causing this and how to correct this?

Adding Desc products below (for brevity I am only listing the relevant fields):

| Field | Type | Null | Key | Default | Extra |

| released_at | datetime | YES | | NULL | |

| updated_at | datetime | YES | | NULL | |

  • 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:53:53+00:00Added an answer on June 5, 2026 at 6:53 am

    The Product model inherits from a model that also defines the released_at attribute. The method for released_at is overloaded in the Ruby on Rails code so that if one would call product.released_at on an instance product of Product, then it would actually call the released_at value on the parent model. As a result, from the rails console it always looks as if released_at is not null and contains a value.

    However, looking at the database directly shows that released_at is null in the Product model and as such, even though the will_paginate request goes through correctly, no ordering is done because the values are all the same (null). In the case where the exact same query is performed on the updated_at attribute, sorting works because that attribute is not null. I missed this because I checked for empty values from the Rails Console rather than in MySQL directly.

    My solution was to define a named_scope on the Product model that sorts based on the value in the parent model. I then call the paginate function on the named scope.

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

Sidebar

Related Questions

I am doing some maintenance on a VB6 Windows application. I have a .Net
I am doing some maintenance on software and have a problem that I do
I'm doing maintenance work on an existing Rails site and am having some problems
So I'm doing some maintenance on a PHP site that is using $_SESSION variables.
I am doing some maintenance on a database for an application that uses the
I'm doing some maintenance work and ran across something like the following: std::string s;
Problem I'm doing some maintenance and changes on a Drupal site, but I'm not
I have a project I am doing some maintenance work on and have got
I have a c# v3.5 framework site that I am doing some maintenance on.
I'm currently doing some maintenance on an application and I've come across a big

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.