Class: Accountability::ProductsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/accountability/products_controller.rb', line 20

def create
  @product = Product.new(product_params)

  if @product.save
    redirect_to accountability_products_path, notice: 'Successfully created new product'
  else
    render :new
  end
end

#destroyObject



38
39
40
41
42
43
44
# File 'app/controllers/accountability/products_controller.rb', line 38

def destroy
  if @product.destroy
    redirect_to accountability_products_path, notice: 'Successfully destroyed product'
  else
    redirect_to accountability_products_path, alert: 'There was an issue destroying product'
  end
end

#editObject



18
# File 'app/controllers/accountability/products_controller.rb', line 18

def edit; end

#indexObject



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

def index
  @products = Product.all
end

#newObject



12
13
14
# File 'app/controllers/accountability/products_controller.rb', line 12

def new
  @product = Product.new
end

#showObject



16
# File 'app/controllers/accountability/products_controller.rb', line 16

def show; end

#updateObject



30
31
32
33
34
35
36
# File 'app/controllers/accountability/products_controller.rb', line 30

def update
  if @product.update(product_params)
    redirect_to accountability_products_path, notice: 'Successfully updated product'
  else
    render :edit
  end
end