Relación de rieles entre formulario y base de datos.

I have a text field in my rails form. How would I be able to allow users to enter a set or comma separated values, for example "12343, 121223, 32212", and store these strings in the database on new rows so that I can easily perform distinct counts on this field.

preguntado el 04 de julio de 12 a las 00:07

1 Respuestas

you can split the field value:

values = param[:field_name].split(', ')
values.each do |v|
  Model.create(:column_name => value)
end

I'm not sure if I understood right, your question is not really precise

Respondido 04 Jul 12, 03:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.