【发布时间】:2014-04-02 16:52:02
【问题描述】:
我正在处理一个项目,我需要在 ActiveAdmin 中使用嵌套表单,我正在关注文档,但我认为最新版本的 ActiveAdmin 中存在错误。我使用的是 rails 4,所以我需要直接从 github (gem 'activeadmin', github: 'gregbell/active_admin') 使用 gem。
这是我的代码:
form do |f|
f.inputs "Mission" do
f.input :level
f.input :points
f.input :title
f.input :description
end
f.has_many :requirements do |r|
r.input :kind, as: :select, collection: %w(text video image)
r.input :count
r.input :description, as: :text
end
f.actions
end
这实际上是在表单底部生成一个“添加新要求”按钮,但是 当我点击它时,该按钮只是将我带到首页(它有一个 # 作为 href 值)而不是生成表单。
任何帮助将不胜感激。 提前致谢
【问题讨论】:
-
我下载了源代码,搜索了has_many.js.coffee,把它变成了play JS,将它粘贴到一个新文件中并包含在我的清单中并且它工作了。
-
您是否在任务模型中添加了accepts_nested_attributes_for :requirements ?
-
那是 4 个月前的事了。我不记得了。我想现在应该可以解决了。
标签: ruby-on-rails-4 activeadmin nested-forms