M
M
Max2016-03-31 18:19:50
Ruby on Rails
Max, 2016-03-31 18:19:50

Why did the submit button on the form stop working to send a record to the database?

Hello, for some reason the "submit" button, which is responsible for sending a record to the database, has stopped working. Everything was fine before. Unfortunately, I did not upload the working version to github.
Here is the code of the form itself (appears when you click on the block).

<%= form_for(@place) do |f| %>
       	<div class="btn btn-primary place_block" id="place_<%= n %>" style="">
     	<p><%= @film_session.cinema.cinema_name %></p>
          <p><%= @film_session.session_name %></p>
          <p>Place № <%= n %></p>
          <div class="hidden-block">
            <a id="group" href="#data_<%= n %>">Booking</a>
          </div>
          <div class="hidden">
            <div id="data_<%= n %>" class="<%= n %>">

              <%= form_for(@place) do |f| %>
                <% if @place.errors.any? %>
                  <div id="error_explanation">
                    <h2><%= pluralize(@place.errors.count, "error") %> prohibited this place from being saved:</h2>
                    <ul>
                    <% @place.errors.full_messages.each do |message| %>
                      <li><%= message %></li>
                    <% end %>
                    </ul>
                  </div>
                <% end %>

                <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 => n %>

                <div class="field">
                  <%= f.label :session_name %><br>
                  <p><%= @film_session.session_name %></p>
                </div>
                <div class="field">
                  <%= f.label :place_number %><br>
                  <p><%= n %></p>
                </div>
                <div class="field">
                  <%= f.label :status %><br>
                  <%= f.check_box :status, class:"form form-control" %>
                </div>
                <br/>
                <div class="actions">
                  <%= f.submit "Booking", :class => "btn btn-primary" %>
                </div>

              <% end %>
            </div>
          </div>
       	</div>
        <% end %>

Action code.
def show
    @booked_places = @film_session.places
    @place = Place.new
    @cinema = Cinema.find(params[:id])
  end

Nothing happens in the console. The button doesn't seem to work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Izotov, 2016-04-08
@railsfun

Remove nesting forms :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question