我有以下ActiveAdmin表单:
form do |f| f.inputs "Timesheet Details" do f.input :jobs_assigned_worker,:label => "Worker",as: :select,collection: Worker.all f.input :worked_time_hours,:label => "Worked Time (Hours)" f.input :worked_time_mins,:label => "Worked Time (Minutes)" f.input :driving_time_hours,:label => "Driving Time (Hours)" f.input :driving_time_mins,:label => "Driving Time (Minutes)" f.input :spent_dollars,:label => "Extra Money Spent" end f.actions end
当我在编辑视图中使用此表单时,选择下拉菜单将自动默认为当前值.然而,在生产中,下拉菜单由于某种原因默认为顶部的空白值(为什么空白值呢?).
编辑
问题似乎是ActiveAdmin不明白关联,并且默认情况下无法选择关联的对象.我需要弄清楚如何为该关联编写f.input.表单用于“时间表”.时间表has_many JobsAssignedWorkers和每个JobsAssignedWorker都有一个Worker.