Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
ROR: Mapping array to get value

I need a small help on ROR.

I have a return from a query and when I do puts result.to_a, I have got:

{"clazz_id"=>1, "staff_id"=>1}
{"clazz_id"=>2, "staff_id"=>1}
{"clazz_id"=>3, "staff_id"=>1}

I have like to convert it to an array of [1, 2, 3] from clazz_id and how can I achieve that?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

if use Active record query can make this direct pluck

results.pluck(:clazz_id)

if you need deal with array of hash can use map or map! like

p results.to_a.map{|e| e["clazz_id"] } 

or can use collect

p results.to_a.collect{|e| e["clazz_id"] } 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!