Class: StaticSlice::Pages

Inherits:
Application
  • Object
show all
Defined in:
app/controllers/pages.rb

Instance Method Summary collapse

Instance Method Details

#create(page) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/controllers/pages.rb', line 27

def create(page)
  @page = Page.new(page)
  if @page.save
    redirect resource(@page), :message => {:notice => "Page was successfully created"}
  else
    message[:error] = "Page failed to be created"
    render :new
  end
end

#delete(id) ⇒ Object

Raises:

  • (NotFound)


47
48
49
50
51
# File 'app/controllers/pages.rb', line 47

def delete(id)
  @page = Page.get(id)
  raise NotFound unless @page
  display @page
end

#destroy(id) ⇒ Object

Raises:

  • (NotFound)


52
53
54
55
56
57
58
59
60
# File 'app/controllers/pages.rb', line 52

def destroy(id)
  @page = Page.get(id)
  raise NotFound unless @page
  if @page.destroy
    redirect resource(:pages)
  else
    raise InternalServerError
  end
end

#edit(id) ⇒ Object

Raises:

  • (NotFound)


20
21
22
23
24
25
# File 'app/controllers/pages.rb', line 20

def edit(id)
  only_provides :html
  @page = Page.get(id)
  raise NotFound unless @page
  display @page
end

#indexObject

provides :xml, :yaml, :js



3
4
5
6
# File 'app/controllers/pages.rb', line 3

def index
  @pages = Page.all
  display @pages
end

#newObject



14
15
16
17
18
# File 'app/controllers/pages.rb', line 14

def new
  only_provides :html
  @page = Page.new
  display @page
end

#show(id) ⇒ Object

Raises:

  • (NotFound)


8
9
10
11
12
# File 'app/controllers/pages.rb', line 8

def show(id)
  @page = Page.get(id)
  raise NotFound unless @page
  display @page
end

#update(id, page) ⇒ Object

Raises:

  • (NotFound)


37
38
39
40
41
42
43
44
45
# File 'app/controllers/pages.rb', line 37

def update(id, page)
  @page = Page.get(id)
  raise NotFound unless @page
  if @page.update_attributes(page)
     redirect resource(@page)
  else
    display @page, :edit
  end
end