Rails 5 - strong parameters: array of hashes

I am sending these parameters on my request:

{"rss":[{"rss":"http://sneakernews.com/feed/","type":"2"},{"type":"4","rss":"https://forum.unity3d.com/forums/-/index.rss"}]}

      

On my controller, I do this:

rss = rss_params[:rss]

def rss_params
    params.permit(:rss => [:type, :rss])
end

      

But I always get this:

["#<ActionController::Parameters:0x007faf809281a0>", "#<ActionController::Parameters:0x007faf700b75a8>"]

      

How to get hashes?

+3


source to share


1 answer


In Rails 5, just iterate over them and then resolve each hash



params.require(:rss).map do |p|
  p.permit(:rss, :type)
end

      

0


source







All Articles