Reputation: 6573
I have a text field in a form for adding tags to a category. I want the input to be a comma separated string like some,test,tags
and have it save that as an array in posgresSQL. My tags column was created with t.string "tags", array: true
.
In my controller I have
category_params[:tags].split(',')
@category = Category.create(category_params)
But when I enter some,test,tags
it shows up in the database as ["ome", "test"]
What have I done wrong here?
Upvotes: 2
Views: 802
Reputation: 6573
Got it working with
tags = category_params[:tags].split(',')
Category.create(category_params.merge({tags:tags}))
Upvotes: 2