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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:27:12+00:00 2026-06-08T09:27:12+00:00

I am trying to grab two columns of data out of a database, using

  • 0

I am trying to grab two columns of data out of a database, using Ruby on Rails ActiveRecord calls and put them into a 2D JSON array for passing to the client.

I have it working for one column. Now I need to get it working for 2 columns.

This is what I have so far for the database call:

select("TOTAL").map{|x| x.TOTAL.ceil}

This is what I have for the controller:

@results = JSON.dump({ :totals => PerformanceResults.find_totals })

This gives me something like this:
{“totals” [145,132,863,693,372,74,838,91,18,172,84,90,373,161,160,173,1910,210,513,14,79,21,84,41,2630,0,93,150,2971]}

To get two columns, this is how I’m starting out, but it’s not going well:

Database call:

select("TOTAL, time_stamp ").map{|x| x.attributes.slice(:x.TOTAL.ceil, x.time_stamp)}

Its telling me “undefined method `TOTAL’ for :x:Symbol”, which I understand, but since I’m new to Ruby on Rails and also JSON, I thought I’d ask for some help in doing this…

My goal is to get this passed to the client: {“totals” [[‘timestamp’, data], [‘timestamp’, data], etc…. ]}

  • 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-08T09:27:14+00:00Added an answer on June 8, 2026 at 9:27 am

    I have solved this on my own using the following for anyone looking for this solution in the future.

    select("TOTAL, time_stamp ").map{|x| [x.TOTAL.ceil, x.time_stamp]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to grab some data from the database using JQuery AJAx, and
I'm trying to teach myself out of curiosity how to grab events between two
I am trying to grab all the td elements between the first two that
I am trying to grab all the id's that are part_number and feed them
Hi I am trying to grab a div from another website using JS. I
I've been trudging through some code for two days trying to figure out why
I am trying to grab consecutive frames from android using opencv VideoCapture class. Actually
I'm having some major issues trying to grab all the data I need for
For more than two days now, I'm trying to grab a list of all
I'm trying to grab the values of specific tags out of a bib file.

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.