Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Created November 7, 2008 10:55
Show Gist options
  • Save jeroenvandijk/22823 to your computer and use it in GitHub Desktop.
Save jeroenvandijk/22823 to your computer and use it in GitHub Desktop.
def fields_for_work_experience(work_experience, &block)
prefix = work_experience.new_record? ? 'new' : 'existing'
# uses the fields_for helper with a block that gives an extra option to the form fields preventing hash and array param clashes (also for date_selects) which
# would otherwise cause a server error.
fields_for("candidate[#{prefix}_work_experience_attributes][]", work_experience) { |wef| wef.with_options :index => "", &block }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment