4

I have two models with following associations:

class Panel < ActiveRecord::Base
  belongs_to :survey
end


class Survey < ActiveRecord::Base
  has_one :panel
end

And I'm using active_admin to manage surveys:

ActiveAdmin.register Survey do
  config.per_page = 20

  actions :index, :edit, :update

  index do
    column 'Survey ID' do |s|
      s.id
    actions defaults: true
  end

  form do |f|
    inputs do
      input :id, input_html: { disabled: true }
    end
    f.actions
  end
end

And now I want to add a field to form to have possibility to change survey panel. I read through all documentation of active_admin but didn't find any similar case... Is this possible to do with ActiveAdmin?

Mateusz Urbański
  • 7,352
  • 15
  • 68
  • 133

1 Answers1

2

You can create forms with nested models using the has_many method, even if your model uses has_one

https://github.com/activeadmin/activeadmin/blob/9c46b14ea0d9b3aaaa3d7520555c9959d06ce7f3/docs/5-forms.md#nested-resources

Timo Schilling
  • 3,003
  • 1
  • 17
  • 29