Skip to content

Instantly share code, notes, and snippets.

@rkellermeyer
Created September 5, 2012 22:27
Show Gist options
  • Save rkellermeyer/3646407 to your computer and use it in GitHub Desktop.
Save rkellermeyer/3646407 to your computer and use it in GitHub Desktop.
No Ransack::Search object was provided to search_form_for! when using ActiveAdmin
MyAppName::Application.routes.draw do
# ...
namespace :admin do
resources :sales do
resources :consignment_items do
collection { post :search_items, to: 'sales#search_consignment_items' }
end
end
end
# ...
end
# in app/admin/sales.rb
ActiveAdmin.register Sale do
# ...
# Available product filter panel
sidebar :available_product_filters, only: [:new, :edit] do
search_form_for @search, url: 'search_consignment_items_admin_sale', remote: true do |f|
f.condition_fields do |c|
render "condition_fields", f: c
end
f.actions('submit')
end
end
member_action :search_consignment_items, method: :post do
@search = ConsignmentItem.ransack(params[:search])
@consignment_items = @search.result
@search.build_condition if @search.conditions.empty?
@search.build_sort if @search.sorts.empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment