# Postgresql Arrays

**URL:** <https://www.ruby-forum.com/t/postgresql-arrays/139385>\
**Category:** Rails\
**Created:** [June 3, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/postgresql-arrays/139385 "2008-06-03T13:47:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![raam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@raam](https://www.ruby-forum.com/u/raam)\
**Post date:** [June 3, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/postgresql-arrays/139385/1 "2008-06-03T13:47:13Z")

</div>

Hi,

I was wondering if anyone knows how ActiveRecord deals with Postgresql  
arrays? Specifically I am trying to figure out how to:  
a) Setup migration that creates the following table:

CREATE TABLE sal\_emp (  
name text,  
pay\_by\_quarter integer[]  
);

b) insert records into this table through activerecord like  
SalEmp.create({:name =\> “Tom”, :pay\_by\_quarter =\> [1,2,3]})  
Is this even possible?

Thanks,

Ram

---

<div class="post-metadata">

**Author:** ![raam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@raam](https://www.ruby-forum.com/u/raam)\
**Post date:** [June 3, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/postgresql-arrays/139385/2 "2008-06-03T15:57:06Z")

</div>

On Tue, 2008-06-03 at 07:46 -0400, Ram R. wrote:

> b) insert records into this table through activerecord like  
> SalEmp.create({:name =\> “Tom”, :pay\_by\_quarter =\> [1,2,3]})  
> Is this even possible?

* * *

You could serialize the array and save the serialized array as a string  
in the database and then break the array apart…all as part of the  
model.

Craig
