How to insert values into array data type field (psql)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • littlemaster
    New Member
    • Apr 2010
    • 25

    How to insert values into array data type field (psql)

    I am having table in psql it has one field as integer array data type.
    From rails application I was not able to insert value in that filed.

    Example:
    Need to add multiple userid in the name field.

    create table users(name integer[],id serial);

    a=10
    obj-User.new
    obj.name='{a}' # this inserting value as a.
    obj.name='{#{a} }' # this giving error.

    If anyone faced and solved this issue , help me.
  • improvcornartist
    Recognized Expert Contributor
    • May 2007
    • 303

    #2
    You need to use double quotes for #{}, so obj.name="{#{a} }".

    Comment

    Working...