我在rails上的active admin on rails有一些问题/问题,特别是不允许的params错误:
下面是现有的active admin参数
根据active admin文档,我应该是正确的,因为rails正在接受dispatch_information模型的其他属性,并且我能够在没有任何问题的情况下读写。就在最近添加的属性"custom_attorney“中。协会已经成立了。当在模型文件上声明一个attr_accessor时,它说这个错误
它似乎无法读取或检测我为dispatch_information模型添加的列,而在我的控制台中它已经在那里了。
当我用attr_accessor添加它时,“虽然它不应该,只是为了继续在表单页面上”,然后我填写了属性需要,我在我的控制台中得到了一些奇怪的东西。
您可以看到,它似乎是在efile_order哈希中而不是dispatch_information_attribute哈希中添加的,在图像的底部,您可以看到它表示不允许的参数,即使我在正确的属性块中添加了它,我们也可以注意到其他属性pf dispatch_information工作得很好,只是最近添加的custom_attorney属性。我已经做了一切像移民之类的事情。
这里是我的表单,我们可以看到输入位于包含dispatch_defendant和dispatch_plaintiff的同一个块上,这两个属性也很好。
我真的不知道我错过了什么。提亚
发布于 2022-05-29 06:49:25
问题是,custom_attorney
应该嵌套在dispatch_information_attributes
下面,您把它放在了错误的位置,因此是不允许的。
正确的方法是为这些属性添加一个块并嵌套它们。
- f.simple_fields_for :dispatch_information do |d|
- d.input :custom_attorney, :input_html => { id: 'new-attorney' }
如果您关心现有的数据,那么为dispatch_information
提供一个对象可能是个好主意。假设您的ivar
名为@e_filling_order
,那么您应该有以下内容。
- f.simple_fields_for :dispatch_information, @e_filling_order.dispatch_information || @e_filling_order.build_dispatch_information do |d|
https://stackoverflow.com/questions/72400656
复制相似问题