setting hstore in rails4, dynamic key/values

前端 未结 3 1055
名媛妹妹
名媛妹妹 2021-01-01 01:52

I\'m playing around with Hstore for the first time in a rails4 app, and I am using javascript in a form to build out dynamic form fields for the hstore column (:schema)

3条回答
  •  梦谈多话
    2021-01-01 02:45

    I think Rails must have simplified this in recent versions (current as of 5.2.3 at least)... and much cleaner/easier:

    params.require(:parent).permit(:name, :whatever, data: {})

    This will allow and store any/all attributes of data into an hstore field. An example of POSTing or PUTing a data nested attribute via HTML:

提交回复
热议问题