Class: Forge::PostCategoriesController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/post_categories_controller.rb

Instance Method Summary collapse

Methods inherited from ForgeController

#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor

Methods inherited from ApplicationController

#app_init

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/forge/app/controllers/forge/post_categories_controller.rb', line 23

def create
  @post_category = .new(params[:post_category])
  if @post_category.save
    flash[:notice] = 'Post category was successfully created.'
    redirect_to(forge_post_categories_path)
  else
    get_post_categories
    render :action => "index"
  end
end

#destroyObject



43
44
45
46
# File 'lib/forge/app/controllers/forge/post_categories_controller.rb', line 43

def destroy
  @post_category.destroy
  redirect_to(forge_post_categories_path)
end

#editObject



16
17
18
19
20
21
# File 'lib/forge/app/controllers/forge/post_categories_controller.rb', line 16

def edit
  respond_to do |format|
    format.js { render :layout => false }
    format.html { }
  end
end

#indexObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/forge/app/controllers/forge/post_categories_controller.rb', line 4

def index
  @post_category = .new
  respond_to do |format|
    format.html { get_post_categories }
    format.js {
      @post_categories = .where("title LIKE ?", "%#{params[:q]}%")
      @post_categories = @post_categories.order(:title)
      render :partial => "post_category", :collection => @post_categories
    }
  end
end

#updateObject



34
35
36
37
38
39
40
41
# File 'lib/forge/app/controllers/forge/post_categories_controller.rb', line 34

def update
  if @post_category.update_attributes(params[:post_category])
    flash[:notice] = 'Post category was successfully updated.'
    redirect_to(forge_post_categories_path)
  else
    render :action => "edit"
  end
end