Rails – Using form_for and fields_for, how do you access the sub-object while in the fields_for block?

I just dealt with this today myself.

You can access the object of the fields_for through:

builder.object

where builder is your fields_for form builder object. In your particular case, you can say:

<p>Enter license for car parked in stall: <%= builder.object.stall_number%></p>

That should do it for you!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)