Jesper Borriboon
Jesper Borriboon

Reputation: 11

How to implement multi form with one submit button in Rails

I'm new to web development and ruby on rails and I'm copying other websites for practice.

Right now I'm trying to make a copy of BiggerPockets "rehab estimator tool", which have several features i would like to implement in my own end project.

I'm not sure how to structure the project and would like some feedback on my ideas.

  1. Model: I was thinking about generating a model "rehabJob" and "rehabReport", making rehabJob correspond to every line (ex. roof replacement, totalOnly, price: 2000 USD) and rehabReport begin a model containing a reportTitle and other rehabJobs (ex roof replacement, paint jobs, new flooring etc.)

  2. How would I submit a form with multiple rehabJob models, with only 1 submit button

  3. Ideas of how to implement the "delete/adding" of new lines (rehabJobs)

The link for the tool: https://www.biggerpockets.com/rehab-estimator/new

Image of biggerpockets rehab estimator tool:

Screenshot 1

Upvotes: 1

Views: 45

Answers (1)

SteveTurczyn
SteveTurczyn

Reputation: 36860

In your shoes I'd take a look at the coccoon gem which provides easy tools for adding / removing nested records. They give easy instructions on usage at their site. https://github.com/nathanvda/cocoon

Upvotes: 2

Related Questions