我有一個像失蹤誤塊3
class CompanyDepartment < ActiveRecord::Base
belongs_to :company
accepts_nested_attributes_for :phones, :allow_destroy => true
attr_accessible :phones_attributes
end
class Phone < ActiveRecord::Base
has_and_belongs_to_many :companies
has_and_belongs_to_many :company_departments
end
某些型號我使用nested_form ryanb寶石。 當我創建新 company_department時,所有作品都很好。 所有手機加入部分作品也不錯。
但是,當我是編輯一些company_department,我有手機添加錯誤 。
這是我的電話訪問量:
#views/company_departments/_tab_contacts.html.haml
%td
#phones
= f.fields_for :phones
= f.link_to_add "add phone", :phones
#views/company_departments/_phone_fields.html.haml
= f.text_field :number
= f.link_to_remove "delete"
錯誤聽起來像
Missing block
Extracted source (around line #7):
#views/company_departments/_tab_contacts.html.haml
...
7: = f.fields_for :phones
...
所以我渲染通過Ajax這個標籤。 當我沒有Ajax錯誤渲染不顯示,所有的作品不錯。 但我需要與阿賈克斯:)
[nested_form readme](https://github.com/ryanb/nested_form)包含沒有塊的變體。當我創建新的公司部門對象時,所有工作都很好,沒有障礙。但是,當我試圖編輯現有的公司部門時,我發現有一個錯誤的塊。我認爲這可能是與AJAX問題... – nub