M
M
Max2016-03-24 19:06:09
Ruby on Rails
Max, 2016-03-24 19:06:09

How to send data from button to database (rails)?

Hello, please tell me how to send the data from the button to the database?
There is a block

<div class="hidden-block">
<% n = 0 %>
    <%= link_to "Booking", new_place_path, :place_number => n, class:"btn btn-primary fancybox" , id:"#{n}" %>
</div>

(The number stored in n is constantly changing.)
I would like to send the number stored in the variable n to the place_number row in the Place table.
But when clicked, it redirects to the new_place_path action. There I left the fields
<div class="field">
    <%= f.label :cinema_id %><br>
    <%= f.number_field :cinema_id %>
  </div>
  <div class="field">
    <%= f.label :film_session_id %><br>
    <%= f.number_field :film_session_id %>
  </div>
  <div class="field">
    <%= f.label :status %><br>
    <%= f.check_box :status %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>

And I predict that the data will be sent to the place_number column automatically. But that doesn't happen. Please tell me how to fix this.
The new_place_path view belongs to a different controller*

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
caution, 2016-03-24
@caution

guides.rubyonrails.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question