Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic forms in rails

So I'm creating a simple application. I have a 'Games' database table and a 'Rules' database table. Each game can have many rules. I want to present a form like this:

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

So the user can click a button to add another text field for additional rules. What is the best way of going about this? Are there form helpers? Any way to return an array of rules? I'm somewhat new to Rails, and my googling didn't provide much help. I may just be being ignorant, but any help would be greatly appreciated!

like image 950
opticon Avatar asked Feb 03 '12 22:02

opticon


1 Answers

What you are looking for are called "dynamic forms" and the answer to your question is in the following Railscasts episode.

  1. http://railscasts.com/episodes/403-dynamic-forms
  2. https://github.com/railscasts/403-dynamic-forms

Its kinda late but i hope it helps someone else.

like image 101
kalibbala Avatar answered Sep 25 '22 15:09

kalibbala