Reputation: 43
I tried following the RailsCasts example to get dynamic forms to work but couldn't get it working right. Basically I have a Project that has_many tasks and I want to be able to dynamically add and remove tasks when creating or editing a project. How can I do this?
Upvotes: 1
Views: 2498
Reputation: 11
Apneadiving is right, but it doesn't really help the new guy.
This is only for ruby on rails 3.1 and probably for 3.2 but I haven't tested it.
If you add the following to your Application_root/app/assets/javascripts/application.js
file (I added it to the last line):
//= require jquery_nested_form
a fresh one looks as follows
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require jquery_nested_form
Or if you are for some reason using prototype:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require prototype_nested_form
Upvotes: 1
Reputation: 115511
Use Ryan Bate's gem directly.
It lies here with documentation. BTW the documentation precisely describes your use case.
Upvotes: 2