TypeError:无法将Array转换为json强参数

时间:2014-04-15 01:34:39

标签: ruby-on-rails ruby json ruby-on-rails-4 strong-parameters

我有一个带有强大参数的rails 4 app:

def product_params
   params.require(:product).permit(:title, :user_id, :info => [:color, :size])
end

但我收到以下错误:

INSERT INTO "products" ("created_at", "info","title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"  [["created_at", Tue, 15 Apr 2014 01:30:31 UTC +00:00], ["info", [{"color"=>"Blue"}]], ["title", "Shoes"], ["updated_at", Tue, 15 Apr 2014 01:30:31 UTC +00:00]]
TypeError: can't cast Array to json: INSERT INTO "products" ("created_at", "info", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"

0 个答案:

没有答案