Rails hashes with unknown keys and strong parameters

前端 未结 4 1476
旧巷少年郎
旧巷少年郎 2021-01-12 20:09

I have a rails application that stores a serialized hash in a field called properties.

The hashes keys are unknown though, so I don\'t know of a way to

4条回答
  •  走了就别回头了
    2021-01-12 20:31

    None of these answers worked for me (using Rails 4.2.4), so I figured out the following workaround:

    def product_params properties_keys = params[:product][:properties].keys params.require(:product).permit(:title, :description, properties: properties_keys) end

    Hope that helps someone.

提交回复
热议问题