platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
763 stars 288 forks source link

Error with :select inputs in forms when bumping to activeadmin_addons 1.8.2 #363

Closed matias-martini closed 3 years ago

matias-martini commented 3 years ago

The Problem

I've got an error message during the definition of a form with a :select input, after bumping to activeadmin_addons 1.8.2.

I put together a sample project (a really really lightweight and incomplete rails project) where you can replicate this error.

The Code

You can find the page definition here and the form definition here.

#app/admin/test.rb
ActiveAdmin.register_page 'Test' do
  content do
    para 'This is a test 😏'
  end

  sidebar 'Filters' do
    render partial: 'filters'
  end
end
#app/views/admin/test/_filters.arb
active_admin_form_for(
  :q,
  html: { class: "custom-filters-form", autocomplete: :off }
) do |f|
  f.input :admin_user, as: :select,
                    required: true,
                    collection: AdminUser.all
  f.submit "Filter"
end

Replication

To replicate the problem just clone the repo and execute the following commands

git clone https://github.com/matias-martini/activeadmin-addons-select-filter.git
cd activeadmin-addons-select-filter
bundler install 
rails db:migrate
rails s

Once the server is running, just open a browser and head to http://localhost:3000/admin/test Credentials:

  email: admin@example.com
  password: password

You will be welcome by this error

image

This very same project is working without problems on activeadmin_addons=1.7.1. You can test this by changing the version of this gem on the Gemfile and re-running bundler and rails server.

Comments

I've tried other types of inputs and got no problems. I only had issues with the type :select.