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

The Archive Base Latest Questions

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

I am constructing a resultset using, @time_spent = TimeEntry.find(:all, :joins => INNER JOIN sometable

  • 0

I am constructing a resultset using,

@time_spent = TimeEntry.find(:all,
                         :joins => "INNER JOIN sometable ON x = y",
                         :select =>"id, subject, spent_on")

And to get column names i am using

@time_spent[index].attributes.keys

But it gives me column names in some random order. How can i get in the order same as in select clause.

Can any one tell on what basis elements are ordered when using attributes.keys?

Any hints would be helpful.
Thnx.

  • 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:58:42+00:00Added an answer on May 31, 2026 at 5:58 am

    The command

    @time_spent[index].attributes
    

    Returns a regular Ruby hash. For ruby 1.8, according to the docs:

    The order in which you traverse a hash by either key or value may seem
    arbitrary, and will generally not be in the insertion order.

    In ruby 1.9, this has changed, and now according to the docs “Hashes enumerate their values in the order that the corresponding keys were inserted.”

    If you really wanted to learn more, you’d have to dig into the internals of your Ruby version, but there’s not much point in that. In ruby 1.8, you can pretty safely expect the keys to come out in an un-helpful order for you, and if you need them in some sort of specific order, you will need to implement that yourself.

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

Sidebar

Related Questions

I'm constructing a Hibernate Criterion, using a subselect as follows DetachedCriteria subselect = DetachedCriteria.forClass(NhmCode.class,
I'm constructing a simple search form for our support ticket database using Lucene.Net, and
I'm trying to get the count of documents within 4 specific sections using the
I'm having issues creating an ActionLink using Preview 5. All the docs I can
Given: Constructing an ADO Connection object from one thread and giving it to another
I'm constructing a simple form in ERB but the HTML produced by the text_field
I am constructing a search page with a textbox and a button for now,
I'm constructing a method to take in an ArrayList(presumably full of objects) and then
I am having trouble constructing a single XPath statement to return two different sets
I am constructing a large HTML document from fragments supplied by users that have

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.