
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
As Rails plugin: rails plugin install git://github.com/grosser/simple_auto_complete.git Or As Gem: gem install simple_autocomplete
Then copy javascripts/css from example folder OR use your own
By default, autocomplete_for
limits the results to 10 entries,
and sorts by the autocomplete field.
class UsersController < ApplicationController
autocomplete_for :user, :name
end
autocomplete_for
takes a third parameter, an options hash which is used in the find:
autocomplete_for :user, :name, :limit => 15, :order => 'created_at DESC'
With :match option you can filter for different columns
# find and order with firstname/lastname
# return full_name of records for auto-completion
autocomplete_for :user, :full_name, :match => [:firstname, :lastname]
With :query and :mask option you can change the generated query
# default: "LOWER(full_name) LIKE('%peter%')"
# now: "full_name LIKE('peter%') AND deleted_at IS NULL"
autocomplete_for :user, :full_name, :query => "%{field} LIKE(%{query}) AND deleted_at IS NULL", :mask => '%{value}%'
With a block you can generate any output you need (ERB allowed):
autocomplete_for :post, :title do |items|
items.map{|item| "#{item.title} -- #{item.id} <%= Time.now %>"}.join("\n")
end
The items passed into the block is an ActiveRecord scope allowing further scopes to be chained:
autocomplete_for :post, :title do |items|
items.for_user(current_user).map(&:title).join("\n")
end
<%= f.text_field :auto_user_name, :class => 'autocomplete', 'data-autocomplete-url'=>autocomplete_for_user_name_users_path %>
map.resources :users, :collection => { :autocomplete_for_user_name => :get}
use any library you like
(includes examples for jquery jquery.js + jquery.autocomplete.js + jquery.autocomplete.css)
jQuery(function($){//on document ready
//autocomplete
$('input.autocomplete').each(function(){
var $input = $(this);
$input.autocomplete($input.attr('data-autocomplete-url'));
});
});
find_by_autocomplete_xxx
on the records modelExample for a post with autocompleted user name:
class User
find_by_autocomplete :name # User.find_by_autocomplete_name('Michael')
end
class Post
has_one :user
autocomplete_for(:user, :name) #--> f.text_field :auto_user_name
# OR
autocomplete_for(:user, :name, :name=>:creator) #--> f.text_field :auto_creator_name (creator must a an User)
end
class Group
has_many :users
add_by_autocomplete(:user, :name) #--> f.text_field :add_by_auto_user_name
end
Inspired by DHH`s 'obstrusive' autocomplete_plugin.
Michael Grosser
michael@grosser.it
Hereby placed under public domain, do what you want, just do not hold me accountable...
FAQs
Unknown package
We found that simple_autocomplete 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.