I am using rails 4 with ActiveAdmin. I created a batch action using a custom form to create a task with a build number for each selected device. This is what my code looks like:
ActiveAdmin.register Device do
def get_builds
builds = []
Build.all.each do |build|
builds << [
"[#{build.resource} - #{build.version}] #{build.file_name}",
build.id
]
end
return builds
end
batch_action :create_task, form: {
build: get_builds()
} do |ids, inputs|
build = Build.find(inputs[:build])
Device.where(id: ids).each do |device|
Task.create({
device: device,
build: build
})
end
redirect_to admin_tasks_path
end
end
My problem is that the build list in the form of a batch action is not refreshing. When I launch my application, it has a list of all available assemblies, but if I add or remove an assembly, the assembly list will not be updated.
This, of course, is because the form parameter evaluates my function only once, but I cannot find documentation about the presence of a “dynamic” form.
source
share