Class: Spree::Admin::SearchController
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- Spree::Admin::SearchController
- Defined in:
- app/controllers/spree/admin/search_controller.rb
Instance Method Summary collapse
- #products ⇒ Object
-
#users ⇒ Object
TODO: Clean this up by moving searching out to user_class_extensions And then JSON building with something like Active Model Serializers.
Methods included from SetsUserLanguageLocaleKey
Instance Method Details
#products ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/spree/admin/search_controller.rb', line 24 def products if params[:ids] # split here may be String#split or Array#split, so we must flatten the results @products = Spree::Product.where(id: params[:ids].split(",").flatten) else @products = Spree::Product.ransack(params[:q]).result end @products = list_products expires_in 15.minutes, public: true headers['Surrogate-Control'] = "max-age=#{15.minutes}" end |
#users ⇒ Object
TODO: Clean this up by moving searching out to user_class_extensions And then JSON building with something like Active Model Serializers
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/spree/admin/search_controller.rb', line 11 def users if params[:ids] # split here may be String#split or Array#split, so we must flatten the results @users = Spree.user_class.where(id: params[:ids].split(',').flatten) else @users = Spree.user_class.ransack({ m: 'or', email_start: params[:q], name_start: params[:q] }).result.limit(10) end end |