active_admin_form_for doesn't recognise model's attributes in form

688 Views Asked by At

I have a form like this:

revoke.html.arb

active_admin_form_for resource, url: revoke_active_admin_payment_subscription_path(resource) do |f|
  f.inputs do
    f.input :suspended_at, as: :datepicker, datepicker_options: { max_date: Date.today.iso8601 }
  end
  f.actions
end

But the view is crashing with this error:

undefined method `suspended_at' for #<Forms::Payment::SubscriptionForm:0x00007f36462aaae8>
Did you mean?  suspended_at_from_model

if I change to use suspended_at_from_model the page loads, but the name, id, and label for the input are all suspended_at_from_model instead of simply suspended_at

Why can't the form accept suspended_at for the input?

1

There are 1 best solutions below

0
On

Sometimes resource is the form, not the model. In this case, you need something like:

active_admin_form_for resource.model, url: revoke_active_admin_payment_subscription_path(resource) do |f|