How to permit arrays with hash in Rails 4?
ruby-on-rails
Solution
You can include nesting arrays, for your example it would be:
params.permit(:user_id, :order_status_id, :delivery_type_id, :delivery_time, order_items: [:count, :item_id])
Others can find out more here - http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html
Problem
There is the following params in Rails 4: ``` {"delivery_time":"10","delivery_type_id":"1","order_items":[{"count":"5","item_id":"1"}],"order_status_id":"1","user_id":"1","action":"create","controller":"api/v1/orders"} ``` There is the following strong params: ``` params.permit(:user_id, :order_status_id, :delivery_type_id, :delivery_time, order_items:[]) ``` But this code returns hash without 'order_items' array. I think the reason is hash in array. Please, tell me, how can I fix it? Thanks in advance