Class: Admin::PagesController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/pages_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#access_denied

Methods included from BaseHelper

#render_subnav

Instance Method Details

#archiveObject



60
61
62
63
64
# File 'app/controllers/admin/pages_controller.rb', line 60

def archive
  page = Page.find(params[:id])
  page.archive!
  redirect_to admin_pages_path
end

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/admin/pages_controller.rb', line 20

def create
  @page = Page.new(params[:page])
  if @page.save
    redirect_to admin_pages_path
  else
    render :new
  end
end

#destroyObject



42
43
44
45
46
# File 'app/controllers/admin/pages_controller.rb', line 42

def destroy
  page = Page.find(params[:id])
  page.destroy
  redirect_to admin_pages_path
end

#editObject



29
30
31
# File 'app/controllers/admin/pages_controller.rb', line 29

def edit
  @page = Page.find(params[:id])
end

#indexObject



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

def index
  @search = Page.includes(:category).search(params[:search])
  @pages = @search.order("created_at desc").page(params[:page])
end

#newObject



16
17
18
# File 'app/controllers/admin/pages_controller.rb', line 16

def new
  @page = Page.new
end

#publishObject



48
49
50
51
52
# File 'app/controllers/admin/pages_controller.rb', line 48

def publish
  page = Page.find(params[:id])
  page.publish!
  redirect_to admin_pages_path
end

#unarchiveObject



66
67
68
69
70
# File 'app/controllers/admin/pages_controller.rb', line 66

def unarchive
  page = Page.find(params[:id])
  page.unarchive!
  redirect_to admin_pages_path
end

#unpublishObject



54
55
56
57
58
# File 'app/controllers/admin/pages_controller.rb', line 54

def unpublish
  page = Page.find(params[:id])
  page.unpublish!
  redirect_to admin_pages_path
end

#updateObject



33
34
35
36
37
38
39
40
# File 'app/controllers/admin/pages_controller.rb', line 33

def update
  @page = Page.find(params[:id])
  if @page.update_attributes(params[:page])
    redirect_to admin_pages_path
  else
    render :edit
  end
end