Rails 3.1 динамические вложенные формы - PullRequest
1 голос
/ 15 августа 2011

Я попытался следовать примеру RailsCasts, чтобы заставить работать динамические формы, но не смог заставить его работать правильно. По сути, у меня есть проект с задачами has_many, и я хочу иметь возможность динамически добавлять и удалять задачи при создании или редактировании проекта. Как я могу это сделать?

Ответы [ 2 ]

2 голосов
/ 15 августа 2011

Используйте драгоценный камень Райана Бэйта напрямую.

Он находится здесь с документацией. Кстати, документация точно описывает ваш вариант использования.

1 голос
/ 04 февраля 2012

Подходит для апноэ, но это не очень помогает новому парню.

Это только для ruby ​​на рельсах 3.1 и, вероятно, для 3.2, но я не проверял его.

Если вы добавите следующее в ваш файл Application_root/app/assets/javascripts/application.js (я добавил его в последнийстрока):

//= require jquery_nested_form

свежий выглядит следующим образом

// 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   

Или, если по какой-то причине вы используете прототип:

// 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...