I’m curious to see how folks code their show & edit templates. Everything I’ve seen says you code them separately, but I never liked having to duplicate the code/layouts. So… I worked out a way to use the same code for both show/edit. I’m wondering how else folks handle this and/or what you think of my approach.
- I code the form/fields in a partial… say _form_body.html.haml
- I render this partial in both the show/edit templates
Certainly worked to DRY up my templates. However, it does mean that I need to code my rspec examples differently, using “expect(page).to have_css(‘input[id=“ee_requisition_requisition_number”]’, value: ‘EB-0001’)” instead of the “have_content” matcher.
Seeral years ago, I had coded up some helpers to handle this so that edit requests generated form fields and show requests generated simple text elements, but found the approach above was simpler and easier to maintain.