title: Storing an array/hash in a text field
body: <p>I would like to store an array or hash in a string field. This field holds instructions for how to use a particular resource. When a person edits the field, I want to capture the date and current user, and store them along with the text the person input. I'm trying to avoid adding extra fields just to capture the date and current user. I would like to simply add one 4000 character text field, and store it there.</p>
  
  <p>It looks like I need to serialize the field in the model. But I'm struggling with how to save the date,current user, and the text in a single field as an array, or a hash if that makes more sense. I created a simple CRUD app to model what I'm trying to do, based on a single model called 'product'. Below is the edit page, and below that is the update function in the controller. How could I capture the current date and user, and store it in the 'description' field? Would this happen in the edit view itself, or should this happen in the update method in the controller?</p>
  
  <pre><code>edit.html.erb
  &lt;%= form_for @product do |f| %&gt;
  &lt;p&gt;
  &lt;%= f.label :name %&gt;&lt;br&gt;
  &lt;%= f.text_field :name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;%= f.label :description %&gt;&lt;br&gt;
  &lt;%= f.text_area :description %&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;%= f.label :price %&gt;&lt;br&gt;
  &lt;%= f.text_area :price %&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;%= f.submit %&gt;
  &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The model</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
  #validates  :name, :price , presence: true
  serialize :description
  end
  </code></pre>
  
  <p>The update method</p>
  
  <pre><code>def update
  @product = Product.find(params[:id])
  if @product.update(product_params)
    redirect_to @product
  else
    render 'edit'
  end
  end  
  </code></pre>