# Arrays into columns

**URL:** <https://www.ruby-forum.com/t/arrays-into-columns/176268>\
**Category:** Rails\
**Created:** [September 28, 2009, 9:23am UTC](https://www.ruby-forum.com/t/arrays-into-columns/176268 "2009-09-28T09:23:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajeev86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sajeev86](https://www.ruby-forum.com/u/sajeev86)\
**Post date:** [September 28, 2009, 9:23am UTC](https://www.ruby-forum.com/t/arrays-into-columns/176268/1 "2009-09-28T09:23:42Z")

</div>

hey (first post jitters…)  
Im a baby in rails web development-please be obvious

How would I get an array as a column set of data?  
Could I just generate the table with:

title:string description:text … list:array

Is array there valid?

If its not possible is there a way to contain a list of data that can  
be added to by the app.

Thanks plenty

---

<div class="post-metadata">

**Author:** ![sajeev86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sajeev86](https://www.ruby-forum.com/u/sajeev86)\
**Post date:** [September 28, 2009, 9:42am UTC](https://www.ruby-forum.com/t/arrays-into-columns/176268/2 "2009-09-28T09:42:26Z")

</div>

2009/9/28 sajeev86 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> If its not possible is there a way to contain a list of data that can  
> be added to by the app.

If I understand correctly you want to put the contents of an entire  
array into a single record in a table. Whilst this is possible by  
encoding the contents into a string this is often not the best  
solution to the underlying problem. Give us some more details of what  
you are trying to achieve, there may be a better way, using has\_many  
and belongs\_to relationships for example. It might be worth your  
while first looking at the rails guides on ActiveRecord relationships  
at [http://guides.rubyonrails.org/](http://guides.rubyonrails.org/) (and also Getting Started if you  
have not already seen that one). These might give some ideas on  
alternative solutions.

Colin

---

<div class="post-metadata">

**Author:** ![sajeev86](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sajeev86](https://www.ruby-forum.com/u/sajeev86)\
**Post date:** [September 28, 2009, 10:53am UTC](https://www.ruby-forum.com/t/arrays-into-columns/176268/3 "2009-09-28T10:53:50Z")

</div>

No, not valid; you want an association. Read here:

> **[Google](https://www.google.com/#hl=en&q=rails+database+cardinality)**
>
> Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
