<h1><%= @territory.name %></h1>
<%= link_to 'List of Territories', territories_path %>
<%= render 'shared/address_form' %>
<table>
<tr>
<td><strong>Name</strong></td>
<td><strong>Street</strong></td>
<td><strong>District</strong></td>
<td><strong>Note</strong></td>
<tr>
<%= @addresses.each do |address| %>
<tr>
<td><%= address.name %></td>
<td><%= address.street %></td>
<td><%= address.district %></td>
<td><%= address.note %></td>
</tr>
<% end %>
</table>
形式我呈現在這裏:
<%= form_for [@territory, @new_address] do |f| %>
<div>
<p>
<%= f.label :address %><br />
<%= f.text_area :address %>
</p>
</div>
<div class='file-wrapper'>
<%= f.submit "Submit" %>
</div>
<% end %>
這裏是領土控制器,其中實例變量地址定義:
class TerritoriesController < ApplicationController
def index
@territories = Territory.all
end
def show
@territory = Territory.find(params[:id])
@new_address = @territory.addresses.build
@addresses = @territory.addresses
end
.
.
.
爲什麼Rails的顯示
#<Address:0x7e088224>#<Address:0x7e0881d4>#<Address:0x7e088134>#<Address:0x7e088094># <Address:0x7e087ff4>#<Address:0x7e087f54>#<Address:0x7e087eb4>#<Address:0x7e087e14>#<Address:0x7e087d74>#<Address:0x7e0bce48>
之後的表格和之前的表格?
感謝 托馬斯
什麼形式?你的代碼從桌面開始。請在此之前顯示代碼。 – Thilo
對不起,我一定遲到了。我剛剛更新了帖子的內容。 – Thomas