Multilevel Nested form not showing in Active Admin

时光总嘲笑我的痴心妄想 提交于 2019-12-07 19:36:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!