我有这个型号:
class Employment < ActiveRecord::Base
accepts_nested_attributes_for :month_lines
end
并形成:
employment.new
= form_for @employment do |f|
= f.fields_for :month_lines do |builder|
= render "/month_lines/fields", :f => builder
month_lines / _fields
= f.number_field :days
我想在部分
中显示month_line.year如何从_fields partial?
中访问month_line对象答案 0 :(得分:3)
这是非常简单的方法,但由于一些奇怪的原因,鲜为人知:
= f.object.year