0

I have this model :

class Employment < ActiveRecord::Base
  accepts_nested_attributes_for :month_lines
end

and there forms :

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

I want to display month_line.year in the partial

How do I access the month_line object from in the _fields partial ?

Gady
  • 1,514
  • 2
  • 16
  • 32
  • Since your local :f is builder, then why doesn't `f.number_field :year` work in the _fields partial? – mill Dec 01 '11 at 16:55
  • I need the display the value of year, not a field. Thanks for the comment – Gady Dec 02 '11 at 07:56

1 Answers1

3

It's very simple way but, for some weird reason, little known:

= f.object.year
lucapette
  • 20,564
  • 6
  • 65
  • 59