Created
September 5, 2012 22:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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