File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -37,3 +37,32 @@ Then implement app/views/admin/posts/_form.html.erb:
37
37
<%= f.inputs :title, :body %>
38
38
<%= f.actions :commit %>
39
39
<% end %>
40
+
41
+ ## Nested Resources
42
+
43
+ You can create forms with nested models using the ` has_many ` method:
44
+
45
+ ActiveAdmin.register Post do
46
+
47
+ form do |f|
48
+ f.inputs "Details" do
49
+ f.input :title
50
+ f.input :published_at, :label => "Publish Post At"
51
+ end
52
+ f.inputs "Content" do
53
+ f.input :body
54
+ end
55
+ f.inputs do
56
+ f.has_many :categories, :allow_destroy => true do |cf|
57
+ cf.input :title
58
+ end
59
+ end
60
+ f.actions
61
+ end
62
+
63
+ end
64
+
65
+ The ` :allow_destroy ` option will add a checkbox to the end of the nested form allowing
66
+ removal of the child object upon submission. Be sure to set ` :allow_destroy => true `
67
+ on the association to use this option.
68
+
You can’t perform that action at this time.
0 commit comments