Answer the question
In order to leave comments, you need to log in
How to write to the database of several objects from one form?
Hello, there are 100 div blocks on the page (each block is a place in the cinema). When selecting multiple blocks, an array is created in which the id of the blocks is written and sent to the ruby variable. Next, the form for adding records to the database is rendered.
<% if @test_test.present? %>
<% @test_test.each do |i| %>
<div class="col-md-6 booking_blocks" id="<%= i %>">
<button class="close" id="close" value="<%= i %>">×</button>
<%= form_for(@place) do |f| %>
<div class="field">
<%= f.hidden_field :cinema_id, :value => @film_session.cinema_id %>
<%= f.label :cinema_name %><br>
<p><%= @cinema.cinema_name %></p>
</div>
<%= f.hidden_field :film_session_id, :value => @film_session.id %>
<%= f.hidden_field :place_number, :value => i %>
<div class="field">
<%= f.label :session_name %><br>
<p><%= @film_session.session_name %></p>
</div>
<div class="field">
<%= f.label :place_number %><br>
<p><%= i %></p>
</div>
<div class="field">
<%= f.label :status %><br>
<%= f.check_box :status, class:"form form-control" %>
</div>
<br/>
<% end %>
</div>
<% end %>
<div class="actions">
<%= submit_tag "Booking", :class => "btn btn-primary" %>
</div>
<% end %>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question