Class: Comable::Admin::ProductsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/comable/admin/products_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
# File 'app/controllers/comable/admin/products_controller.rb', line 17

def create
  if @product.update_attributes(product_params)
    redirect_to comable.admin_product_path(@product), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :new
  end
end

#destroyObject



35
36
37
38
39
40
41
42
# File 'app/controllers/comable/admin/products_controller.rb', line 35

def destroy
  if @product.destroy
    redirect_to comable.admin_products_path, notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :edit
  end
end

#indexObject



12
13
14
15
# File 'app/controllers/comable/admin/products_controller.rb', line 12

def index
  @q = Comable::Product.ransack(params[:q])
  @products = @q.result.includes(:stocks).page(params[:page]).accessible_by(current_ability)
end

#showObject



8
9
10
# File 'app/controllers/comable/admin/products_controller.rb', line 8

def show
  render :edit
end

#updateObject



26
27
28
29
30
31
32
33
# File 'app/controllers/comable/admin/products_controller.rb', line 26

def update
  if @product.update_attributes(product_params)
    redirect_to comable.admin_product_path(@product), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :edit
  end
end