Class: Adminpanel::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/adminpanel/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/controllers/adminpanel/categories_controller.rb', line 11

def create
	@category = Category.new(params[:category])
	if @category.save
		redirect_to categories_path, :notice => "La categoria ha sido guardada"
	else
		render "new"
	end
end

#destroy ⇒ Object



34
35
36
37
38
39
# File 'app/controllers/adminpanel/categories_controller.rb', line 34

def destroy
	@category = Category.find(params[:id])
	@category.destroy

	redirect_to categories_path
end

#edit ⇒ Object



20
21
22
# File 'app/controllers/adminpanel/categories_controller.rb', line 20

def edit
	@category = Category.find(params[:id])
end

#index ⇒ Object



3
4
5
# File 'app/controllers/adminpanel/categories_controller.rb', line 3

def index
	@categories = Category.all
end

#new ⇒ Object



7
8
9
# File 'app/controllers/adminpanel/categories_controller.rb', line 7

def new
	@category = Category.new
end

#update ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'app/controllers/adminpanel/categories_controller.rb', line 24

def update
	@category = Category.find(params[:id])

	if @category.update_attributes(params[:category])
		redirect_to categories_path, :notice => "#{@category.name} ha sido actualizado con exito"
	else
		render "edit"
	end
end