Passing in an array as a value in an object with PostgreSQL

Hey guys! So I’m using ruby and postgresSQL for this application.

So I’ve created a class called Train and made a method called #save. Now I’ve made a spec for the save method but when i run rspec I get the following error:

1) Train #save saves an instance of Train into the DB
     Failure/Error: DB.exec("INSERT INTO trains (stops, ticket, name) VALUES ('#{@stops}', '#{@ticket}', '#{@name}') RETURNING id")

       ERROR: malformed array literal: "["lansing", "flint"]"
       LINE 1: INSERT INTO trains (stops, ticket, name) VALUES ('["lansing"...
       DETAIL: "[" must introduce explicitly-specified array dimensions.
     # ./lib/trains.rb:27:in `exec'
     # ./lib/trains.rb:27:in `save'
     # ./spec/trains_spec.rb:23:in `block (3 levels) in <top (required)>'

 I did some digging on PostgreSQL and noticed that colums in an array need to be wrapped in curly braces, but obviously in the code below, I just can’t replace brackets with curly braces or that would throw an error:

describe("#save") do
    it("saves an instance of Train into the DB") do
      train ={:stops => ['lansing', 'flint'], :ticket => "thirty-five", :name => "Flintsing", :id => nil})

So is there anyway I could change my save method to make my save spec pass?

class Train
  attr_reader(:stops, :ticket, :name, :id)

  def initialize(attributes)
    @stops = attributes.fetch(:stops)
    @ticket = attributes.fetch(:ticket)
    @id = attributes.fetch(:id)
    @name = attributes.fetch(:name)

def save()
    DB.exec("INSERT INTO trains (stops, ticket, name) VALUES ('#{@stops}', '#{@ticket}', '#{@name}') RETURNING id")

The variable @stops outputs my array, for example, like in my spec i passed in lansing and flint so it would return [‘lansing’, ‘flint’] as an array. I can’t find any good documentation or answers on how to solve this so I figured I’d ask some fellow developers!