title: save hash in database in ruby on rails
body: <p>I'm trying to save a hash in my database but this does not work</p>
  
  <p>this is my table in my database</p>
  
  <pre><code>create_table "categories", force: :cascade do |t|
      t.string  "name",      limit: 255
      t.integer "client_id", limit: 4
      t.integer "event_id",  limit: 4
      t.text    "color",     limit: 65535
    end
  </code></pre>
  
  <p>in my model try with <code>serialize</code></p>
  
  <pre><code>class Category &lt; ActiveRecord::Base
    serialize :color, Hash
  end
  </code></pre>
  
  <p>in my controller:</p>
  
  <pre><code>def category_params
        params.require(:category).permit(:name, :color, :event_id)
  end
  </code></pre>
  
  <p>when I try to save it I get this in my console:</p>
  
  <pre><code> Parameters: {"category"=&gt;{"event_id"=&gt;"2", "name"=&gt;"dwdqwd", "color"=&gt;{"color"=&gt;"#ad1d1d", "opacity"=&gt;1}}}
  
  Unpermitted parameter: color
  
  SQL (0.4ms)  INSERT INTO `categories` (`name`, `event_id`) VALUES ('dwdqwd', 2)
  </code></pre>
  
  <p>How can I save the hash in my database?</p>