1
我有一個鏈接,它爲我帶來了一個模式窗口。Rails 4 + Ruby 2中的動態嵌套表單
例子:
link_to "@#{client_name(i)}",
account_client_path(current_account.id,i.client_id),
:remote => true,
class: "client-link",
"data-toggle" => "modal", "data-target" => "client-dialog-form"
在此窗口中我想爲這個模型稱爲Issue
形式:
class Issue < ActiveRecord::Base
before_save { self.number = number.downcase }
validate :number, presence: true,
uniqueness: { case_sensitive: false },
length: { maximum: 50 }
has_many :items
accepts_nested_attributes_for :items
end
class Item < ActiveRecord::Base
belongs_to :issue
end
我的問題是,我希望我的Issue
有動態生成的嵌套項目的子窗體。什麼是最好的方式來做到這一點?我在這裏搜索了很多,但都沒有成功。
謝謝,Rich。是的,我確實想通過ajax或某些寶石在飛行中添加額外的字段。我發現迄今爲止稱爲繭的寶石(https://github.com/nathanvda/cocoon)。 – bvlucena
嗨Rich,你是否介意指導我如何在飛行中添加額外的字段?在這種情況下,檢索'item'的html鏈接(單個文本字段名爲info)? –