delegate to :class rather than 'self.class'
Refactor to not call path.ast twice
Do not call fields_for from form_for, to avoid instantiating two builders
Eliminate the usage of parent_builder option from form_for

Just use it internally from fields_for until we come up with a better solution.
Move the hidden :id field logic to where it belongs to

When dealing with nested forms, Rails automatically generates a hidden
field with the id value of the current object being generated by
fields_for. This logic was inside the method that's available from the
template object, but we just need it when really dealing with nested
attributes, so moving the code to here makes more sense.
Refactor the logic that checks whether or not to emit the hidden id field

By checking for object.persisted? first, we avoid the hash lookups for
new objects.
Merge pull request #8777 from goshakkk/delegate-class

Delegate to :class rather than 'self.class'