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?
array: true? It seems to me this is your problem. You have a common string field comma separated. I think you don't need this.category_params[:tags].split(',')doesn't mutate the value right? DoesCategory.create(category_params.merge(tags: params[:tags].split(',')))work as expected?Category.create(category_params.merge(tags: params[:tags].split(',')))didn't work but I did something similar that did work.