Class: Workarea::Admin::CategorizationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/admin/categorizations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
# File 'app/controllers/workarea/admin/categorizations_controller.rb', line 12

def create
  Catalog::Category.in(id: params[:category_ids]).each do |category|
    category.add_product(@product.id)
  end

  flash[:success] = t('workarea.admin.categorizations.flash_messages.added')
  redirect_to catalog_product_categorizations_path(@product)
end

#destroyObject



21
22
23
24
25
26
27
# File 'app/controllers/workarea/admin/categorizations_controller.rb', line 21

def destroy
  category = Catalog::Category.find_by(slug: params[:id])
  category.remove_product(@product.id)

  flash[:success] = t('workarea.admin.categorizations.flash_messages.removed')
  head :ok
end

#indexObject



9
10
# File 'app/controllers/workarea/admin/categorizations_controller.rb', line 9

def index
end