0

Basically I have 3 fields in the database table and I want to return a an array to represent each row.

sqlite database resultset:

row 1)
name: John
gender: male
email: [email protected]

row 2)
name: Sarah
gender: female
email: [email protected]

Desired format from the above resultset:

[['John',male,'[email protected]'],['Sarah',female,'[email protected]']]

I've tried using User.all.map(&:name) but that only gives me ['John','Sarah']

2 Answers 2

3

You'll want to use map, but like this:

User.all.map {|u| [u.name, u.gender, u.email]}
Sign up to request clarification or add additional context in comments.

Comments

0
User.all.map {|u| [u.name, u.gender, u.email] }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.