如何创建没有字段集的格式化嵌套输入?
我有一个表User
,它继承自一个名为Person
的表
,长话短说,而不必执行以下操作:
f.inputs 'Something' do
f.inputs for: :person do |f|
f.input :name
f.input :surname
end
f.input :account
end
这会在内部生成一个fieldset
一个 ol ,它本身是无效的,但这不是我担心的。我想摆脱 fieldset
以便所有属性都显示在同一级别。
f.inputs 'Something' do
f.input :name, for: :person
f.input :surname, for: :person
f.input :account
end
当然这是无效的,输入中没有 for: 这样的东西。
我正在考虑使用委托,但后来我想到在 Person
模型中也有很多 accepts_nested_attributes_for
并且它们会损坏。
此外,Person
表正被另一个模型继承。
有没有任何宝石可以透明化这一点并允许我继承模型?
I have a table User
that inherits from a table called Person
Long story short, instead of having to do the following:
f.inputs 'Something' do
f.inputs for: :person do |f|
f.input :name
f.input :surname
end
f.input :account
end
This generates an fieldset
inside an ol
, which is by itself invalid, but that's not what worries me. I want to get rid of the fieldset
so all the attributes are shown at the same level.
f.inputs 'Something' do
f.input :name, for: :person
f.input :surname, for: :person
f.input :account
end
Of course that is not valid, there is not such thing as a for: in the input.
I was thinking about using delegate, but then I though that I also have a lot of accepts_nested_attributes_for
in the Person
model and them would broke.
Also the Person
table is being inherited by another model.
There is any gem that transparentize this and allow me to just inherit the model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
semantic_fields_for
代替inputs
:Use
semantic_fields_for
instead ofinputs
: