Class: ProductsController
Instance Method Summary
collapse
included
#current_ability
#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets
included
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#edit ⇒ Object
33
34
35
|
# File 'app/controllers/products_controller.rb', line 33
def edit
@product = Product.find(params[:id])
end
|
#index ⇒ Object
10
11
12
|
# File 'app/controllers/products_controller.rb', line 10
def index
@products = Product.all
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/products_controller.rb', line 18
def new
@product = Product.new
end
|
#resource ⇒ Object
53
54
55
|
# File 'app/controllers/products_controller.rb', line 53
def resource
@product
end
|
#show ⇒ Object
14
15
16
|
# File 'app/controllers/products_controller.rb', line 14
def show
@product = Product.find(params[:id])
end
|
#update ⇒ Object
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
|