Class: Admin::PagesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 39

def create
  params[:page][:group_ids] ||= []
  @page = Page.new(params[:page])
  respond_to do |format|
    if @page.save
      format.html { redirect_to admin_pages_path(:anchor => "node-#{@page.id}"), :notice => 'Page was successfully created.' }
    else
      format.html { render :action => "new" }
    end
    format.js
  end
end

#destroyObject



65
66
67
68
69
70
71
72
73
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 65

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

  respond_to do |format|
    format.html { redirect_to admin_pages_url }
    format.js
  end
end

#editObject



35
36
37
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 35

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

#indexObject



3
4
5
6
7
8
9
10
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 3

def index
  @pages = Page.all

  respond_to do |format|
    format.html
    format.json { render :json => @pages }
  end
end

#newObject

GET /pages/new GET /pages/new.json



25
26
27
28
29
30
31
32
33
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 25

def new
  @parent = Page.find(params[:parent_id]) if params[:parent_id].present?
  @page = @parent? @parent.children.new : Page.new

  respond_to do |format|
    format.html # new.html.erb
    format.js {render :partial => 'inline_form'}
  end
end

#showObject

GET /pages/1 GET /pages/1.json



14
15
16
17
18
19
20
21
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 14

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

  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @page }
  end
end

#updateObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/amalgam/admin/pages_controller.rb', line 52

def update
  params[:page][:group_ids] ||= []
  @page = Page.find(params[:id])
  respond_to do |format|
    if @page.update_attributes(params[:page])
      format.html { redirect_to :back, :notice => 'Page was successfully updated.' }
    else
      format.html { render :action=> "edit" }
    end
    format.js
  end
end