Class: ProductsController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/products_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



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

def create
  @product = Product.new(params[:product])
  @product.user_id = current_user.id
  
  if @product.save
    redirect_to product_path(@product), notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



47
48
49
50
51
# File 'app/controllers/products_controller.rb', line 47

def destroy
  @product = Product.find(params[:id])
  @product.destroy
  redirect_to products_url, notice: t('general.form.destroyed')
end

#editObject



33
34
35
# File 'app/controllers/products_controller.rb', line 33

def edit
  @product = Product.find(params[:id])
end

#indexObject



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

def index
  @products = Product.all
end

#newObject



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

def new
  @product = Product.new
end

#resourceObject



53
54
55
# File 'app/controllers/products_controller.rb', line 53

def resource
  @product
end

#showObject



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

def show
  @product = Product.find(params[:id])
end

#updateObject



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

def update
  @product = Product.find(params[:id])
  
  if @product.update_attributes(params[:product])
    redirect_to product_path(@product), notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end