I am having trouble finding any information on how to iterate through an array and create objects. 

My form creates a selectable list of users that when checked, pass the user\_ids as an array object. 

invitations\new.html.rb

```
<%= bootstrap_form_for Invitation.new do |f| %>
<br>
  <ul>
    <%= f.hidden_field :attended_event_id, :value => @event_selected.id %>
    <li>
    <%= check_box_tag 'attendee_id[]', user.id %>
    <%= h user.name %>
    </li>
    <% end %>
  </ul>
<br>
<%= f.submit "Invite Selected Users" %>
<% end %>

```

I would like to then create new Invitations objects by combining the attended\_event\_id with all of the objects in the attendee\_id array. 

After a bit of trouble I got the basics of my controller working but only by passing in the user\_id as a text entry. Below is my Invitations controller. Not really sure where to start on this one as I haven't been able to find a good example. 

invitations\_controller.rb

```
  def create
     @invitation = Invitation.new(invite_params)

     if @invitation.save!
      flash.now[:success] = "Invited!"
       redirect_to root_path
     else
      flash.now[:error] = "Failure!"
      redirect_to root_path
     end
  end

  private
  def invite_params

    params.require(:invitation).permit(:attended_event_id, :attendee_id)
  end
end

```