Class: Admin::CategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/cornerstone/admin/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /cornerstone/admin/categories/



18
19
20
21
22
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 18

def create
  @category = Category.new(params[:category])
  flash[:notice] = 'Category was successfully created.' if @category.save
  respond_with(:admin, @category, :location => admin_categories_path)
end

#destroyObject

DELETE /cornerstone/admin/categories/:id



38
39
40
41
42
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 38

def destroy
  @category = Category.find(params[:id])
  flash[:notice] = 'Category was successfully destroyed.' if @category.destroy
  respond_with([:admin, @category], :location => admin_categories_path)
end

#editObject

GET /cornerstone/admin/categories/:id/edit



25
26
27
28
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 25

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

#indexObject



6
7
8
9
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 6

def index
  @discussion_categories = Category.discussions
  @article_categories = Category.articles
end

#newObject

GET /cornerstone/admin/categories/new



12
13
14
15
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 12

def new
  @category = Category.new
  respond_with(:admin, @category)
end

#updateObject

PUT /cornerstone/admin/categories/:id



31
32
33
34
35
# File 'app/controllers/cornerstone/admin/categories_controller.rb', line 31

def update
  @category = Category.find(params[:id])
  flash[:notice] = 'Category was successfully updated.' if @category.update_attributes(params[:category])
  respond_with(:admin, @category, :location => admin_categories_path)
end