title: Rails - How to accept an array of JSON objects
body: <p>How do I accept an array of JSON objects on my rails site? I post something like</p>
  
  <pre><code>{'team':{'name':'Titans'}}
  </code></pre>
  
  <p>However, if I try to post a JSON with an array of objects. It only saves the 1st object.</p>
  
  <pre><code>{'team':[{'name':'Titans'},{'name':'Dragons'},{'name':'Falcons'}]}
  </code></pre>
  
  <p>My goal is to send multiple 'teams' in 1 JSON file. What do I have to write on the Rails side?</p>
  
  <p>On the rails side, I have something like</p>
  
  <pre><code>def create
    @team = Team.new(params[:team])
    @team.user_id = current_user.id
  
    respond_to do |format|
      if @team.save
        format.html { redirect_to(@team, :notice =&gt; 'Team was successfully created.') }
        format.json  { render :json =&gt; @team, :status =&gt; :created, :location =&gt; @team }
      else
        format.html { render :action =&gt; "new" }
        format.json  { render :json =&gt; @team.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end
  </code></pre>
  
  <p>Do I take the params: and for each element, create a new team or something? I'm new to ruby so any help would be appreciated.</p>