0
在我的Ruby on Rails應用程序時,去一個特定的頁面我有booking_line查看以下表格:Ruby on Rails的點擊「f.submit」
<%= form_for @booking_line do |f| %>
<%= f.hidden_field :showing_id %>
<%= image_tag "thor_hammer.jpg",:size => "900x250" %>
<td width="300px"> <br><%= f.label :seat_id, 'Please Select a Seat:' %>
<br><%= f.collection_select :seat_id, free_seats, :id,:seats_available %><br>
</td>
<td width="300px">
<div class="actions">
<%= f.submit %>
</div>
<br>
<%= render "/error_messages", :message_header => "Cannot save: ", :target => @booking_line %>
</td>
<% end %>
但是,因爲這是booking_line,我想什麼發生的是,當點擊提交按鈕時,它創建一個預訂和一個booking_line,因爲在booking_line表中它具有booking_id
這個屬性,因此這兩者之間建立了關聯。我怎樣才能做到這一點?
你定義的關係?預訂可以有很多booking_line或只有一個booking_line? – Sontya 2015-02-23 10:21:43
請列出你的協會(對於BookingLine,Booking和Seat) – 2015-02-23 10:54:10