Class: IshManager::CoTailorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/co_tailors_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_productObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/ish_manager/co_tailors_controller.rb', line 9

def create_product
  authorize! :create, ::CoTailors::Product
  @product = ::CoTailors::Product.new params[:co_tailors_product].permit!
  if @product.save
    flash[:notice] = 'Created product'
  else
    flash[:alert] = 'Cannot create product: ', @product.errors.messages.to_s
  end
  redirect_to :action => 'home'
end

#homeObject



4
5
6
7
# File 'app/controllers/ish_manager/co_tailors_controller.rb', line 4

def home
  authorize! :home, ::CoTailors
  @products = ::CoTailors::Product.all
end

#update_productObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/ish_manager/co_tailors_controller.rb', line 20

def update_product
  @product = ::CoTailors::Product.find params[:id]
  authorize! :update, @product
  if @product.update_attributes params[:co_tailors_product].permit!
    flash[:notice] = 'updated product'
  else
    flash[:alert] = 'Cannot update product: ', @product.errors.messages.to_s
  end
  redirect_to :action => 'home'
end