
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
active_admin_auto_select
Advanced tools
This gem is a nifty UI widget, which combines the Select2 library, PostgeSQL and ActiveAdmin, for helping you filter records in ActiveAdmin using auto-completion, based on certain database columns of your choice.
Add this line to your application's Gemfile:
gem 'active_admin_auto_select'
Currently, Select2 3.5 is required. Select2 versions 4+ are not compatible as the API contains breaking changes. We are looking to remedy this as soon as possible.
And then execute:
> bundle
Add the following directives to your Javascript manifest file:
//= require select2
//= require underscore
//= require autoselect
Or for Coffeescript flavor, add this:
#= require select2
#= require underscore
#= require autoselect
Add the following directive to your Stylesheet manifest file:
@import "select2";
After installing the gem, you have to add some lines into the ActiveAdmin controller you want to auto_select.
For example, say you want to add the widget in order to filter to the users' id
filter, by searching in their full names or emails:
auto_select
method in order to create the collection_actionauto_select :first_name, :last_name, :email,
{
'users_with_properties' => ->{ User.joins(:properties).uniq }
}
In the example above, first_name
, :last_name
and :email
are the database columns that help you find the desired user.
Anything that is typed into the autocomplete field will be lookup in the columns specified here. Last argument is a Hash of
scopes that will make sense by reading through the next example.
filter
in your controllerfilter :id_eq, label: 'User',
input_html: {
data: {
scope: 'users_with_properties',
url: 'users/autoselect',
placeholder: 'Select a user'
}
}
:id_eq
(required) is the column being filtered id
+ the _eq
suffix (Ransack style).data-scope
option is the desired scope that will be used by the widget in order to fetch the similar users.data-url
(required) is the url generated by the action, which is defined in the ActiveAdmin controller.AutoSelect
Javascript class in your active_admin's javascript file.$(document).ready ->
newAutoSelect = new AutoSelect(input: $('#q_id_eq'))
newAutoSelect.init()
Where #q_user_id_eq
use the generated input's id
of the filter you added. For instance,
if your filter's name in the ActiveAdmin controller is defined as id_eq
, then the id
attribute of the generated input will be q_id_eq
.
Bug reports and pull requests are welcome on GitHub at https://github.com/spyrbri/admin_auto_select. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that active_admin_auto_select demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.