jeudi 22 février 2018

How to Store the text fields array data in database without using loop using rails

I am new in ror and I am trying from 4 hours to store the data of form of textfields array like this

<input type="text" name="custom_field[names][]" class="form-control full-width" placeholder =  "Name">

<input type="text" name="custom_field[length_limit][]" class="form-control full-width" placeholder =  "Length Limit">

I want to store the arrays coming into the form in database columns of name and length limit. I don't want to use loop to do this job.

I am doing this in controller

user = CustomField.create(:name=> params[:names])

But it is giving ERROR: null value in column "name" violates not-null constraint DETAI

I am using postgresql

How can I do this?

Aucun commentaire:

Enregistrer un commentaire