Dynamic forms in rails

So, I am creating a simple application. I have a Games database table and a Rules database table. There can be many rules in every game. I want to submit this form:

Game Title:
Game Description:
  Rule #1: 
  (Click to add another rule)

Thus, the user can click the button to add another text box for additional rules. What is the best way to get around this? Are there any helpers? Any way to return an array of rules? I'm a little new to Rails, and my search engine did not provide much help. I may just be ignorant, but any help would be greatly appreciated!

+5
source share
5 answers

This is old, but should be identical to what you are trying to do in the kernel.

http://railscasts.com/episodes/75-complex-forms-part-3

Project Tasks Game Rules.

+3

You will probably want to use the "game" form with nested "rules" formats. It would be a long answer if I put all the necessary code, but visiting them should help you:

http://railscasts.com/episodes/196-nested-model-form-part-1

http://railscasts.com/episodes/197-nested-model-form-part-2

+1
source

All Articles