问题
I'm trying to Implement a multilevel Nested form.
These are my models
workout.rb
has_many :workout_weeks
accepts_nested_attributes_for :workout_weeks
workout_week.rb
belongs_to :workout
has_many :workout_days
accepts_nested_attributes_for :workout_days
workout_day.rb
belongs_to :workout_week
and my workout edit part in active admin is like
form do |f|
inputs 'Workout Details' do
f.input :workout_name
f.inputs do
f.has_many :workout_weeks, heading: 'Workout Week', allow_destroy: true do |ww|
ww.input :week_workout_name
ww.inputs do
ww.has_many :workout_days, heading: 'Workout Days', allow_destroy: true do |wd|
wd.input :day_workout_name
end
end
end
end
f.actions
end
end
Did I miss anything here, The form for edit field is not available in the view. Its not generated. My view is like this now.
Why is my workout_day form not getting rendered here ?
回答1:
This should work:
form do |f|
inputs 'Workout Details' do
f.input :workout_name
f.inputs do
f.has_many :workout_weeks, heading: 'Workout Week', allow_destroy: true do |ww|
ww.input :week_workout_name
ww.has_many :workout_days, heading: 'Workout Days', allow_destroy: true do |wd|
wd.input :day_workout_name
end
end
end
f.actions
end
end
you can't put a inputs
in a inputs
来源:https://stackoverflow.com/questions/32563922/multilevel-nested-form-not-showing-in-active-admin