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



20
21
22
23
24
25
26
27
28
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 20

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



39
40
41
42
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 39

def destroy
  @product_category.destroy
  redirect_to(forge_product_categories_path)
end

#editObject



13
14
15
16
17
18
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 13

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

#indexObject



4
5
6
7
8
9
10
11
# 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
    }
  end
end

#reorderObject



45
46
47
48
49
50
51
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 45

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



30
31
32
33
34
35
36
37
# File 'lib/forge/app/controllers/forge/product_categories_controller.rb', line 30

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