Class: Wacky::PagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wacky/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/wacky/pages_controller.rb', line 12

def create
  @page = Page.new
  @page.slug = params[:page]['slug']
  @page.body = params[:page]['body']
  if @page.save
    redirect_to @page, notice: "Page created successfully."
  else
    render 'new', error: 'There was a problem creating the page.'
  end
end

#editObject



23
24
25
# File 'app/controllers/wacky/pages_controller.rb', line 23

def edit
  load_page
end

#newObject



7
8
9
10
# File 'app/controllers/wacky/pages_controller.rb', line 7

def new
  @page = Page.new
  @page.slug = params[:id]
end

#revert_to_versionObject



43
44
45
46
47
48
# File 'app/controllers/wacky/pages_controller.rb', line 43

def revert_to_version
  load_page
  @page = @page.versions[params[:version].to_i].reify
  @page.save
  redirect_to @page
end

#showObject



3
4
5
# File 'app/controllers/wacky/pages_controller.rb', line 3

def show
  load_page
end

#updateObject



27
28
29
30
31
32
# File 'app/controllers/wacky/pages_controller.rb', line 27

def update
  load_page
  @page.body = params[:page]['body']
  @page.save
  redirect_to @page
end

#versionObject



38
39
40
41
# File 'app/controllers/wacky/pages_controller.rb', line 38

def version
  load_page
  @page = @page.versions[params[:version].to_i].reify
end

#versionsObject



34
35
36
# File 'app/controllers/wacky/pages_controller.rb', line 34

def versions
  load_page
end