Using RoR 4, and SQlite3 for development, mySQL for production.
Given a table "Things":
POSITION NAME VALUE CODE
1 Animal Dog 1
1 Animal Cat 2
1 Animal Bird 3
2 Place USA 1
2 Place Other 2
3 Color Red a
3 Color Blue b
3 Color Orange c
4 Age Young a
4 Age Middle b
4 Age Old c
5 Alive Yes y
5 Alive No n
How can I read the table into an array that looks like this:
a = [["1", "Animal", "Dog", "1"],
["1", "Animal", "Cat", "2"],
["1", "Animal", "Bird", "3"],
["2", "Place", "USA", "1"],
["2", "Place", "Other", "2"],
["3", "Color", "Red", "a"],
["3", "Color", "Blue", "b"],
["3", "Color", "Orange", "c"],
["4", "Age", "Young", "a"],
["4", "Age", "Middle", "b"],
["4", "Age", "Old", "c"],
["5", "Alive", "Yes", "y"],
["5", "Alive", "No", "n"]]
You can have a try.
Just:
I think it does the trick.
Edited
If you want all the fields:
If you want each row to be a Hash: