SachinJadhav
SachinJadhav

Reputation: 1

Rails ActiveRecord fetch records with appropriate data types

I am using Ruby, I want data in array of hash format.

I have tried out ActiveRecord's select_al method. But it returns all the data in string format, does not matter what type is its type in data base. All numbers are also returned in string format.

Upvotes: 0

Views: 443

Answers (1)

giorgian
giorgian

Reputation: 3825

You could use:

MyModel.all.map &:attributes

Which is equivalent to:

MyModel.find(:all).collect {|x| x.attributes}

Upvotes: 4

Related Questions