Class: Admin::Page::CategoriesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/page/categories_controller.rb

Direct Known Subclasses

CategoriesController

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/admin/page/categories_controller.rb', line 13

def create
  @category = @section.categories.build params[:category]
  if @category.save
    flash[:notice] = t(:'adva.categories.flash.create.success')
    redirect_to [:admin, @site, @section, :categories]
  else
    flash.now[:error] = t(:'adva.categories.flash.create.failure')
    render :action => "new"
  end
end

#destroyObject



43
44
45
46
47
48
49
50
51
# File 'app/controllers/admin/page/categories_controller.rb', line 43

def destroy
  if @category.destroy
    flash[:notice] = t(:'adva.categories.flash.destroy.success')
    redirect_to [:admin, @site, @section, :categories]
  else
    flash.now[:error] = t(:'adva.categories.flash.destroy.failure')
    render :action => 'edit'
  end
end

#indexObject



6
7
# File 'app/controllers/admin/page/categories_controller.rb', line 6

def index
end

#newObject



9
10
11
# File 'app/controllers/admin/page/categories_controller.rb', line 9

def new
  @category = @section.categories.build
end

#updateObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/admin/page/categories_controller.rb', line 24

def update
  if @category.update_attributes params[:category]
    flash[:notice] = t(:'adva.categories.flash.update.success')
    redirect_to [:admin, @site, @section, :categories]
  else
    flash.now[:error] = t(:'adva.categories.flash.update.failure')
    render :action => 'edit'
  end
end

#update_allObject



34
35
36
37
38
39
40
41
# File 'app/controllers/admin/page/categories_controller.rb', line 34

def update_all
  # FIXME we currently use :update_all to update the position for a single object
  # instead we should either use :update_all to batch update all objects on this
  # resource or use :update. applies to articles, sections, categories etc.
  @section.categories.update(params[:categories].keys, params[:categories].values)
  @section.categories.update_paths!
  render :text => 'OK'
end