使用 Ruby 1.8.6 和 Rails 1.2。
型号:Job
, JobExtraStop
:
class JobExtraStop < ActiveRecord::Base
belongs_to :job
end
class Job < ActiveRecord::Base
belongs_to :lead, :foreign_key => :id
has_one :quote, :foreign_key => :id
has_many :credit_card
has_many :job_extra_stops
end
查看代码:
主视图
<%= render_partial 'jobs/job_address_stop_fields', "stop" => stop, "index"=> index %>
部分称为:
<span class="jasf" id="lead_form_adrr_fields">
<% fields_for "job_extra_stop[#{index}]", stop do |extra_stop_form| %>
<tr>
<td><%= extra_stop_form.text_field :st_num, :size => 2%></td>
<td><%= extra_stop_form.text_field :st_name, :size => 15%></td>
<td><%= extra_stop_form.text_field :apt_num, :size => 2%></td>
<td><%= extra_stop_form.text_field :city, :size => 9%></td>
<td><%= extra_stop_form.text_field :zip, :size => 5%></td>
<td><%= extra_stop_form.select(:state,( [[ "Select State", "" ]] + State::NAMES)) %>
</td>
<td><%= extra_stop_form.text_field :floor, :size => 2%></td>
<td> <%= extra_stop_form.text_field :elevator, :size => 1%></td>
<td> <%= extra_stop_form.text_field :action_type, :size => 5%></td>
<td> <%= extra_stop_form.select(:location_type, ([["pick-up"],["drop-off"],["extra_stop"]] )) %></td>
<td> <%= extra_stop_form.text_field :note, :size => 10%></td>
<td>^ / v</td>
<td> <%= link_to_function "Remove", "$(this).up('.jasf').remove()" %></td>
</tr>
<% end %>
</span>
错误:
未定义的局部变量或方法索引
不知道我做错了什么。