Class: Admin::BlogCategoriesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/admin/blog_categories_controller.rb', line 16

def create
  @blog_category = BlogCategory.new params[:blog_category]
  if @blog_category.save
    flash[:notice] = 'Successfully created the blog_category.'
    redirect_to @blog_category.root? ? admin_blog_category_path(@blog_category) : admin_blog_category_path(@blog_category.parent)
  else
    render :action => 'new'
  end
end

#destroyObject



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

def destroy
  @blog_category.destroy
  flash[:notice] = 'Successfully destroyed the blog_category.'
  redirect_to @blog_category.root? ? admin_blog_categories_path : admin_blog_category_path(@blog_category.parent)
end

#editObject



26
27
# File 'app/controllers/admin/blog_categories_controller.rb', line 26

def edit
end

#indexObject



5
6
7
# File 'app/controllers/admin/blog_categories_controller.rb', line 5

def index
  @blog_categories = BlogCategory.roots
end

#newObject



12
13
14
# File 'app/controllers/admin/blog_categories_controller.rb', line 12

def new
  @blog_category = BlogCategory.new :parent_id => params[:parent_id]
end

#showObject



9
10
# File 'app/controllers/admin/blog_categories_controller.rb', line 9

def show
end

#updateObject



29
30
31
32
33
34
35
36
# File 'app/controllers/admin/blog_categories_controller.rb', line 29

def update
  if @blog_category.update_attributes params[:blog_category]
    flash[:notice] = 'Successfully updated the blog_category.'
    redirect_to admin_blog_categories_path
  else
    render :action => 'edit'
  end
end