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.
Instance Method Details
#products ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/admin/search_controller.rb', line 27 def products if params[:ids] @products = Product.where(id: params[:ids].split(",").flatten) else @products = Product.ransack(params[:q]).result end @products = @products.distinct.page(params[:page]).per(params[:per_page]) 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/spree/admin/search_controller.rb', line 12 def users if params[:ids] @users = Spree.user_class.where(id: params[:ids].split(',').flatten) else @users = Spree.user_class.ransack({ m: 'or', email_start: params[:q], ship_address_firstname_start: params[:q], ship_address_lastname_start: params[:q], bill_address_firstname_start: params[:q], bill_address_lastname_start: params[:q] }).result.limit(10) end end |