Class: SolidusAdmin::PromotionsController

Inherits:
BaseController
  • Object
show all
Includes:
ControllerHelpers::Search
Defined in:
app/controllers/solidus_admin/promotions_controller.rb

Instance Method Summary collapse

Methods included from ComponentsHelper

#component

Instance Method Details

#destroyObject



26
27
28
29
30
31
32
33
# File 'app/controllers/solidus_admin/promotions_controller.rb', line 26

def destroy
  @promotions = Spree::Promotion.where(id: params[:id])

  Spree::Promotion.transaction { @promotions.destroy_all }

  flash[:notice] = t('.success')
  redirect_back_or_to promotions_path, status: :see_other
end

#indexObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/solidus_admin/promotions_controller.rb', line 13

def index
  promotions = apply_search_to(
    Spree::Promotion.order(id: :desc),
    param: :q,
  )

  set_page_and_extract_portion_from(promotions)

  respond_to do |format|
    format.html { render component('promotions/index').new(page: @page) }
  end
end