Rails 5 now returns params as a class instance, no longer a hash.
due to the requirement to have random hashs key based on user input,
the only way to do this is to force this value by calling .to_unsafe_h
example:
res = params.require(:detail).permit(:name, :year)
res[:specification] = params[: detail][:specification].to_unsafe_h
but if you do know your hash key, call this instead:
permit(:specification => { :keyname1, keyname2 }
if you have any suggestion, please comment :)
https://forum.upcase.com/t/rails-doesnt-recognize-a-request-as-patch/5115
http://eileencodes.com/posts/actioncontroller-parameters-now-returns-an-object-instead-of-a-hash/
No comments:
Post a Comment