I have a hash field in my Rails model and am attempting to update it.
The attribute, detail
, was first generated through a migration as a text
type. Afterwords, in my model, it was set as a hash
through the store :detail
property
class Request < ActiveRecord::Base
store :detail
end
My strong_params are as such:
params.require(:request).permit(:name, :action, :detail => {})
However, when my Parameters go through as
Parameters: {"request"=>{"name"=>"temp", "action"=>"create", "detail"=>{"test"=>"fdsf"}}}
I am told that there is an Unpermitted parameter: test
, despite the test
parameter being part of the detail
hash.
How do I fix this? Thanks!
params.require(:request).permit(:name, :action, detail: [:test])
Another option (e. g. if you do not know the possible field names in advance) would be to serialize the detail
to json string on client side, accept it as string and deserialize to a hash afterwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With