# How to make data from the db into an array

**URL:** <https://www.ruby-forum.com/t/how-to-make-data-from-the-db-into-an-array/128219>\
**Category:** Rails\
**Created:** [February 5, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/how-to-make-data-from-the-db-into-an-array/128219 "2008-02-05T23:24:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezer85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@dezer85](https://www.ruby-forum.com/u/dezer85)\
**Post date:** [February 5, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/how-to-make-data-from-the-db-into-an-array/128219/1 "2008-02-05T23:24:09Z")

</div>

As the title says i need to make a db field into an array the db field  
is of the type text and could for an example look like this:

Blues, Elektronisk, Jazz, Klassisk, Metal, Rock

and i can get it by typing @spec.music\_style

i need to use it in a for each loop, and tried to do this

\<% [@spec.music\_style].each do |music\_style| %\>

but it doesn’t seem to work

Regards Benjamin
