I have a simple API built using
rails new my_api --api
Then
rails g scaffold Model name age
I can make a new record using curl POST request like so
curl -H "Accept: application/json" -H "Content-type: application/json" -d '{"name": "Fred", "age": "5"}' "http://localhost:3000/model_name"
Question
Is it possible to submit multiple new records in the same POST request? And if so, what should the JSON look like?
What I've tried so far
I've tried variations of {"name": "Fred", "age": "5"}, like {"name": ["Fred", "Mary"], "age": ["5", "6"]}
The API doesn't reject this JSON, instead, it creates 1 record (not 2), and the values are nil instead of the actual data.
Note
The current controller code is
  def create
    @model = Model.new(model_params)
    if @model.save
      render json: @model, status: :created, location: @model
    else
      render json: @model.errors, status: :unprocessable_entity
    end
  end
 
     
    