Note that there are some explanatory texts on larger screens.

plurals
  1. POBest Practice for Creating a Modular Form Spanning Several Different Layouts
    text
    copied!<p>I'm a RoR newbie (v3.2.13), and I'm building a new site/application that has a lot of landing pages, divided into 6-8 different layouts. The layouts are using similar elements in a changing order, so I'm using partials and layout inheritance to render each page appropriately.</p> <p>My problem is that my forms (located at the top of each page) are also inconsistent (for example, while one page might only have a "name" and "email" fields, another will contain an additional "phone" field, a third one might also include a "password", "address" and "country" fields, etc.), and building a different partial for each page seems like a very prodigal approach, DRY wise, not to mention how ineffective it is, especially since I expect a vast amount of new pages in the future.</p> <p>I've researched the forms concept thoroughly but have yet to come up with a solution that I deem good enough, probably due to me being a newbie. Unfortunately I don't have any code to present, since I waited until I make a decision regarding the optimal approach to start coding.</p> <p>What I came up with so far is using jQuery and conditionals within Haml, which I understand are both naive approaches, while I read coding each field into its own partial would be considered an anti-pattern (alternatively - NOT the Rails 3 way).</p> <p>Is there a best practice pertaining to such design issues? Are there any online/other resources I missed that would point me in the right direction?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload