[英]RoR - Nested Attributes - Chain of Tables
I understood the option: 我了解以下选项:
accepts_nested_attributes_for
When I need to manipulate 2 tables trough 1 form, or 1 controller I can use that. 当我需要通过1种形式或2个控制器操纵2个表时,可以使用它。
Before I try something that I didn't find answear let me know if I will break something in rails philosophy. 在尝试一些我没有发现的东西之前,请让我知道我是否会破坏Rails哲学中的某些东西。
I have a chain of tables in my database: 我的数据库中有一系列表:
TableA
has_many :TableB
end
TableB
belongs_to :TableA
has_many:TableC
end
TableC
belongs_to :TableB
has_many :TableD
end
Adn so on... It stops somewhere. Adn等等...停在某处。
Let me try an scenario with 5 tables in this pattern. 让我尝试以这种模式使用5个表的场景。 If I use the first table, in the context above it's that TableA, can I manipulate all 5 tables at the same time?
如果使用第一个表,在上面的上下文中就是TableA,是否可以同时操作所有5个表? I mean, at the same controller?
我的意思是,在同一控制器上? Same form, using that nested attributes => A accepts B, B accepts C, and so on?
同样的形式,使用嵌套属性=> A接受B,B接受C,依此类推? Am I wrong thinking that way?
我这样想错了吗?
Thanks, you've been so nice! 谢谢,你真好!
*pattern example: country has many states, states has many cities, cities has many... *模式示例:国家有很多州,州有很多城市,城市有很多...
Yes you can do that. 是的,你可以这么做。 That could leave you with a very complicated form for your users though.
不过,这可能会使您的用户使用非常复杂的表格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.