Class: Forge::ProductCategoriesController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/product_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



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

def create
  @product_category = ProductCategory.new(params[:product_category])
  if @product_category.save
    flash[:notice] = 'Product category was successfully created.'
    redirect_to(forge_product_categories_path)
  else
    render :action => :index
  end
end

#destroyObject



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

def destroy
  @product_category.destroy
  redirect_to(forge_product_categories_path)
end

#editObject



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

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

#indexObject



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

def index
  respond_to do |format|
    format.html {
      @product_categories = ProductCategory.paginate(:per_page => 10, :page => params[:page])
      @product_category = ProductCategory.new
    }
    format.js {
      @product_categories = ProductCategory.where("title LIKE ?", "%#{params[:q]}%")
      render :partial => "product_category", :collection => @product_categories
    }
  end
end

#reorderObject



49
50
51
52
53
54
55
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 49

def reorder
  ProductCategory.reorder!(params[:product_category_list])
  respond_to do |format|
    format.js { render :nothing => true }
    format.html { redirect_to :action => :index }
  end
end

#updateObject



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

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