author avatar

sujay

Tue Aug 22 2023

When using Rails strong parameters feature to permit certain parameters in controller and if any specific param has array values, we need to permit it as an array explicitly

Eg:
Request: /api/v1/calendar.json?date_from=&date_to=&hotel_id[]=1&hotel_id[]=2

def permit_params
  params.permit(:date_from, :date_to, hotel_id: []) # hotel_id: [] is important
end