【发布时间】:2016-02-11 19:53:35
【问题描述】:
使用 Ryan 的 nested_form gem 创建表单。我想要link_to_add 和link_to_remove 方法的功能,但是这个表单与我的任何模型都没有任何关系;我根本没有保存它。
= simple_nested_form_for :non_model_object do |f|
= f.input :input1
= f.simple_fields_for :non_model_child do |child|
= child.input :child_input_1
= child.link_to_remove 'Remove'
= f.link_to_add 'Add', :non_model_child
non_model_object 显然不是我在数据库中的东西。 non_model_object“有很多”non_model_children 为了这种形式,但同样,这在数据库中也不存在。我收到的错误是:
Invalid association. Make sure that accepts_nested_attributes_for is used for :non_model_child association.
这显然是有道理的,但我不能将它添加到 non_model_object 类中,因为它不存在。
此表单的目的只是让用户填写它,它会向我发送他们输入的 csv。关于如何最好地实现这一点的想法?
谢谢!
导轨 4.2.5.1 红宝石 2.1.2 nested_form 0.3.2
【问题讨论】:
标签: ruby-on-rails ruby associations nested-forms