If you use simple_form, you can do something like this:
f.simple_fields_for :dynamic do |dynamic_f| @product.dynamic.each do |k,v| dynamic_f.input k.to_sym end end
Remember to specify the parameters in the controller as follows:
params.require(:product).permit(dynamic: [:name, :description, :title, :author, :creation_date]])
It is always recommended to use a whitelist of the specific parameters that you need, but if you want to allow everything inside the dynamic, you can try something like this:
params.require(:product)permit( **permitted paramters in here** ).tap do |whitelisted| whitelisted[:dynamic] = params[:product][:dynamic] if params[:product][:dynamic] end
Or allow everything for the product model:
params.require(:product).permit!
This is not recommended as it will leave your other data outside the json field open for rewriting.
source share