I've just started Rails and I'm working on a simple logging app where I have a database (Mongodb) and Rails 3.x.x
The user is going to input, via text_area, 3 short text (:what) that will be stored in the database:
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :Users
field :what, :type => String
field :created, :type => Date, :default => Time.now
validates_length_of :what, minimum: 10
What is the preferred method when I want to add three of the same field into one field in the database? My failing form (just to illustrate what I want to do)
= form_for :days, :class => 'form-horizontal' do |f|
%table.table
- for i in 1..3 do
%tr
%td
%h2= i
%td
= f.text_area_tag 'what_[]', :size => "200x5"
The above form will not work. If I set:
f.text_area :what
that will only send the content of the last text area to controller. What is the best way to deal with that kind of structure? Looking forward to your beautiful answers!