I'm trying to save a hash in my database but this does not work
this is my table in my database
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
in my model try with serialize
class Category < ActiveRecord::Base
serialize :color, Hash
end
in my controller:
def category_params
params.require(:category).permit(:name, :color, :event_id)
end
when I try to save it I get this in my console:
Parameters: {"category"=>{"event_id"=>"2", "name"=>"dwdqwd", "color"=>{"color"=>"#ad1d1d", "opacity"=>1}}}
Unpermitted parameter: color
SQL (0.4ms) INSERT INTO `categories` (`name`, `event_id`) VALUES ('dwdqwd', 2)
How can I save the hash in my database?