Post and save as array to postgres db.
<% ['auto', 'homeowners', 'health'].map do |service| %>
  <div class="element element-float">
    <%= check_box_tag 'agent[agent_services]', [service] %> <%= service %>
  </div>
<% end %>
Currently submitting the form will only save the last item on the page checked. So if I try to check "auto" and "homeowners" only "homeowners" is saved. Rails log:
"agent"=>{"agent_services"=>"homeowners"}
What I need to do is save all of the checked elements into ROW#agent_services as an array. So if I check "auto" and "homeowners", I need the following to happen:
"agent"=>{"agent_services"=>["auto", "homeowners"]}
I can do this with js but I want to know the rails way. Also the next problem is that postgresql#agent_services == String .. Is there a way to make this row accept an array?
Thanks!
Having an issue saving to postgres
column is add_column :agents, :agent_services, :string, array: true
params.require(:agent).permit( . . . , :agent_services => [])
Processing by AgentsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"t/aqjJWwd24czZNXKVS5q9yjf6WU15/artpAaXtb28s=", "agent"=>{"agent_services"=>["auto", "homeowners", "health"]}, "button"=>"", "id"=>"60"}
  Agent Load (0.3ms)  SELECT  "agents".* FROM "agents"  WHERE "agents"."id" = $1 LIMIT 1  [["id", 60]]
   (0.1ms)  BEGIN
  SQL (0.5ms)  UPDATE "agents" SET "agent_services" = $1, "updated_at" = $2 WHERE "agents"."id" = 60  [["agent_services", "{\"auto\",\"homeowners\",\"health\"}"], ["updated_at", "2014-09-17 18:50:52.190149"]]
PG::DatatypeMismatch: ERROR:  column "agent_services" is of type character varying[] but expression is of type character varying at character 40
HINT:  You will need to rewrite or cast the expression.
: UPDATE "agents" SET "agent_services" = $1, "updated_at" = $2 WHERE "agents"."id" = 60
   (0.1ms)  ROLLBACK
 
    