Class: StaticSlice::Pages
- Inherits:
-
Application
- Object
- Merb::Controller
- Application
- StaticSlice::Pages
- Defined in:
- app/controllers/pages.rb
Instance Method Summary collapse
- #create(page) ⇒ Object
- #delete(id) ⇒ Object
- #destroy(id) ⇒ Object
- #edit(id) ⇒ Object
-
#index ⇒ Object
provides :xml, :yaml, :js.
- #new ⇒ Object
- #show(id) ⇒ Object
- #update(id, page) ⇒ Object
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 [:error] = "Page failed to be created" render :new end end |
#delete(id) ⇒ Object
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
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
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 |
#index ⇒ Object
provides :xml, :yaml, :js
3 4 5 6 |
# File 'app/controllers/pages.rb', line 3 def index @pages = Page.all display @pages end |
#new ⇒ Object
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
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
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 |