Class: Accountability::ProductsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @product = Product.new(product_params)

  if params[:stage] == 'initial'
    @stage = 'final'
    render :new
  elsif @product.save
    redirect_to accountability_products_path, notice: 'Successfully created new product'
  else
    render :new
  end
end

#destroyObject



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

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



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

def edit; end

#indexObject



6
7
8
# File 'app/controllers/accountability/products_controller.rb', line 6

def index
  @products = Product.all
end

#newObject



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

def new
  @product = Product.new
  @stage = 'initial'
end

#showObject



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

def show; end

#updateObject



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

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