Active_admin autocomplete with rails3-jquery auto-computer

I have a problem using rails3-jquery-autocomplete gem with active_admin

I am using the latest version of active_admin (from git), which now relies on formtastic 2, and I am using 1.04 rails3-jquery-autocomplete

undefined local variable or method `autocomplete_artist_name_records_path' for #<ActiveAdmin::DSL:0x007fde797140d0> 

Do not like the URL route that I provide, any ideas what I can do wrong?

gems

 gem 'activeadmin', :git => 'git://github.com/gregbell/active_admin.git' gem 'rails3-jquery-autocomplete', '~> 1.0.4' 

records.rb (active_admin)

 ActiveAdmin.register Record do #... controller do autocomplete :artist, :name#, :full => true end form do |f| f.input :artist_name, :as => :autocomplete, :url => autocomplete_artist_name_records_path end end 

routes.rb

  resources :records do get :autocomplete_artist_name, :on => :collection end 

I also tried this fix, which I found somewhere, but didn't change anything, including the error

https://gist.github.com/1137340

+6
source share
2 answers
  • Added admin namespace in routes.rb

     # Put this line above ActiveAdmin.routes. Otherwise, you may get this error # ActiveRecord::RecordNotFound (Couldn't find Record with id=autocomplete_artist_name): namespace :admin do resources :records do get :autocomplete_artist_name, :on => :collection end end ActiveAdmin.routes(self) 
  • Added these lines to app/assets/javascript/active_admin.js

     //= require jquery //= require jquery_ujs //= require jquery-ui //= require autocomplete-rails 
  • In app/admin/records.rb my workaround is using the url in the string instead of the path method

     form do |f| f.input :artist_name, :as => :autocomplete, :url => '/admin/records/autocomplete_artist_name' f.buttons end 
  • Installed jquery css to make the autocomplete suggestion box beautiful. See this post . Then edit app/assets/stylesheets/active_admin.css.scss to enable jquery-ui css

+3
source

The form block is executed in the DSL ActiveAdmins area.

Try submitting the form in partial access to the URL helpers.

 ActiveAdmin.register Post do form :partial => "form" end 

http://activeadmin.info/docs/5-forms.html

+1
source

Source: https://habr.com/ru/post/900342/


All Articles