我在我的红宝石应用程序中有3个类。如何在红宝石中保存嵌套类?
class EmployeeDetail < ActiveRecord::Base
belongs_to :ContactDetails
end
class ContactDetails < ActiveRecord::Base
belongs_to :communicationAddress, :class_name=>'Address'
belongs_to :permanentAddress, :class_name=>'Address'
end
class Address < ActiveRecord::Base
attr_accessible :city, :country, :pin, :state, :street
end
我的要求是为EmployeeDetail创建视图并从同一页保存communicationAddress和permanentAddress。
任何人都可以告诉我什么应该是_form.html.erb为EmployeeDetail的可能结构,以及我必须在控制器中做出什么样的修改来保存地址。
thnks
谷歌我得到了它。但是当我去编辑页面时,地址字段没有得到填充值。我不知道为什么? –
可以请你提供一些解决方案,为什么编辑不工作??? –