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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:39:36+00:00 2026-05-28T00:39:36+00:00

Apparently I’m missing something obvious here, but would appreciate a quick example. I’ve got

  • 0

Apparently I’m missing something obvious here, but would appreciate a quick example.

I’ve got a record coming back from ActiveRecord where I have a few columns selected from a query. The fields are of BigDecimal format and need to be flattened to string.

I had initially thought it was sufficient to pull the query with:

rows = ModelName.order("date DESC").select('table_name.precise_number1, table_name.precise_number2').limit(100).all.zip
rows_stringified1 = Array.new
rows_stringified2 = Array.new

readings.each do |row|
  rows_stringified1.push row[:precise_number1].to_s
  rows_stringified2.push row[:precise_number2].to_s
end

However, this yields an error such as can't convert Symbol into Integer. Obviously I’m not following exactly how to access columns from records in a row set result.

How would you normally do this?

  • 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-28T00:39:36+00:00Added an answer on May 28, 2026 at 12:39 am

    Presumably you have a typo and you’re doing this:

    readings = ModelName.order("date DESC").
                         select('table_name.precise_number1, table_name.precise_number2').
                         limit(100).
                         all.
                         zip
    

    instead of assigning to rows. Noticed that zip at the end? That doesn’t make any sense. When you do this:

    [a, b, c].zip
    

    you get this:

    [[a], [b], [c]]
    

    So, in your readings.each block, the row is in fact [model] rather than the model that you think it is and that means that row[:precise_number1] is trying to access the Array row using the Symbol :precise_number1 instead of the Integer that the Array expects, hence your “can’t convert Symbol into Integer” error.

    So either get rid of the zip and leave your each as-is:

    readings = ModelName.order("date DESC").
                         select('table_name.precise_number1, table_name.precise_number2').
                         limit(100).
                         all
    # ...
    readings.each do |row|
      rows_stringified1.push row[:precise_number1].to_s
      rows_stringified2.push row[:precise_number2].to_s
    end
    

    or keep the zip and adjust your each block to match what row really looks like:

    readings = ModelName.order("date DESC").
                         select('table_name.precise_number1, table_name.precise_number2').
                         limit(100).
                         all.
                         zip
    # ...
    readings.each do |row|
      rows_stringified1.push row.first[:precise_number1].to_s
      rows_stringified2.push row.first[:precise_number2].to_s
    end
    

    I’d recommend getting rid of the zip as it does nothing useful and just confuses things.

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

Sidebar

Related Questions

Apparently, I'm missing something fundamental. I'm having a problem with formatting the value of
Apparently I don't understand something about binding ListBox controls to data. Here is a
Apparently xrange is faster but I have no idea why it's faster (and no
Apparently we use the Scrum development methodology. Here's generally how it goes: Developers thrash
Apparently you can easily obtain a client IP address in WCF 3.5 but not
Apparently many people have run into this problem, but I have yet to be
Apparently, you can't call apply with a record constructor: (defrecord Foo. [id field]) (apply
Apparently I've done something I'm not aware of All my classes now have warnings
Apparently Python only supports 2 minor versions (like 2.X), so that would mean Python
Apparently Mac keyboards don't have an Insert key (or maybe they do but I

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.