I have integrated select2 with my active admin. But it is not working properly. It only showing the drop down without the search option.
I have followed the following link: (Select2-rails is not working with ActiveAdmin)
Used Ruby Version: ruby-2.6.3 [ x86_64 ] Rails Version: Rails 5.0.7.2
This is my app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap.min
//= require_tree .
//= require select2
//= require select2_locale_pt-BR
$( "#dropdown" ).select2({
language: "zh-TW"
});
This is my app/assets/stylesheets/application.css
*= require bootstrap
*= require_tree .
*= require_self
*= require select2
*= require select2-bootstrap
I have used select2 here,
customer_location.input :area, as: :select2, collection: Region.all.map {|u| [u.area.to_s, u.id]}, :input_html => { :class => 'select2-input', :width => 'auto', "data-placeholder" => 'Select Area' }
I used activeadmin-select2
gemwhich worked fine for me.Add
activeadmin,jquery-railsandselect2-railsto your Gemfile:And add
activeadmin-select2to your Gemfile:gem 'activeadmin-select2', github: 'mfairburn/activeadmin-select2'Add the activeadmin-select2 calls to the active_admin stylesheets and javascripts with:
@import "active_admin/select2/base";#add this line to your app/assets/stylesheets/active_admin.scss#= require active_admin/select2#add this line to your app/assets/javascripts/active_admin.jsUsage:
Filters
Standard :select filters will automagically be converted to Select2 filters. If you want a multi-select combo-box then use:
Select Lists
To use a Select2 style list simply change from :select to :select2 or :select2_multiple