
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.
administrate-field-lazy_has_many
Advanced tools
An input field that shows search results of has many association, lazily from a custom endpoint.
Add this line to your application's Gemfile:
gem 'administrate-field-lazy_has_many'
And then execute:
$ bundle
Or install it yourself as:
$ gem install administrate-field-lazy_has_many
You need to have a route that does the following:
[{value: 1, text: option1}]
search
attributeresult_limit
The best way is to re-use everything administrate search feature. You must define this action in administrate related entity controller
def books_data
result_limit = params[:result_limit] || 10
search_term = params[:search].to_s.strip
resources = Administrate::Search.new(scoped_resource, dashboard_class, search_term).run
resources = resources.limit(result_limit).map do |resource|
{ value: resource.id, text: dashboard.display_resource(resource) }
end
if resources.blank?
render_empty_array
else
render json: resources
end
end
Above example action that could work for every model, but you can change the implementation as per need. The only catch is it must return the comply with above conditions.
Field is pretty easy and it does support all the features of administrate has_many field. You can provide all has_many options as per your use case.
The only require attribute is action
which must be rails path helper.
require "administrate/base_dashboard"
class PostDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::String,
title: Field::String,
contributors: Field::LazyHasMany.with_options(
action: 'admin_form_contributors_data_path', result_limit: 10
),
created_at: Field::DateTime,
updated_at: Field::DateTime
}.freeze
# ...
end
i.e result_limit
attribute maximum result value the field will post to action endpoint with search
paramter
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that administrate-field-lazy_has_many 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.