Class: Wacky::PagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Wacky::PagesController
- Defined in:
- app/controllers/wacky/pages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #revert_to_version ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #version ⇒ Object
- #versions ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#edit ⇒ Object
23 24 25 |
# File 'app/controllers/wacky/pages_controller.rb', line 23 def edit load_page end |
#new ⇒ Object
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_version ⇒ Object
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 |
#show ⇒ Object
3 4 5 |
# File 'app/controllers/wacky/pages_controller.rb', line 3 def show load_page end |
#update ⇒ Object
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 |
#version ⇒ Object
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 |
#versions ⇒ Object
34 35 36 |
# File 'app/controllers/wacky/pages_controller.rb', line 34 def versions load_page end |