Skip to content
Browse files

Fixing DELETE

  • Loading branch information...
1 parent 9556374 commit 81a8e432f72618ad03851f03a908f53598083749 @dafrancis committed
Showing with 13 additions and 13 deletions.
  1. +5 −3 main.rb
  2. +2 −2 views/_newform.haml
  3. +1 −1 views/edit_slide.haml
  4. +1 −1 views/index.haml
  5. +1 −3 views/layout.haml
  6. +1 −1 views/new_slide.haml
  7. +2 −2 views/presentation.haml
View
8 main.rb
@@ -1,9 +1,11 @@
require 'sinatra/base'
+require 'sinatra/reloader'
require 'haml'
require 'data_mapper'
require 'rdiscount'
class DeckTheHalls < Sinatra::Base
+ use Rack::MethodOverride
# Load Helpers
Dir["./helpers/*.rb"].each do |file|
require file
@@ -22,7 +24,7 @@ class DeckTheHalls < Sinatra::Base
DataMapper.auto_upgrade!
enable :sessions
- set :public, './public'
+ set :public_folder, './public'
get '/' do
haml :index
@@ -58,7 +60,7 @@ class DeckTheHalls < Sinatra::Base
slide = Slide.first(:id => params[:id])
pres = slide.presentation
slide.destroy
- redirect "/pres/#{pres}"
+ redirect "/pres/#{pres.id}"
end
get '/pres/view/:id' do
@@ -73,7 +75,7 @@ class DeckTheHalls < Sinatra::Base
delete '/pres/:id' do
pres = Presentation.get(params[:id])
- pres.destroy
+ pres.destroy!
redirect "/"
end
end
View
4 views/_newform.haml
@@ -1,5 +1,5 @@
%form{:method=>'POST', :action=>'/new'}
- %label{:for=>'pres_title'} Title
+ %label{:for=>'pres_title'} Title:&nbsp;
%input{:type => 'text', :name => 'presentation[title]', :id=>'pres_title'}
%select{:name => 'presentation[style]'}
-Dir["./public/themes/style/*.css"].each do |file|
@@ -9,4 +9,4 @@
-Dir["./public/themes/transition/*.css"].each do |file|
-file = file.gsub(%r{(./public/themes/transition/|.css)},'')
%option{:value=>file}= file.capitalize
- %input{:type => 'submit', :value => 'New Presentation'}
+ %input.btn{:type => 'submit', :value => 'New Presentation'}
View
2 views/edit_slide.haml
@@ -2,4 +2,4 @@
%form{:action=>'/pres/slide/edit', :method => 'POST'}
%input{:type=>'hidden', :name=>'slide', :value=>params[:id]}
%textarea{:name=>'content',:cols=>'200',:rows=>'8'}= @slide.content
- %input{:type=>'submit',:value=>'Save'}
+ %input.btn{:type=>'submit',:value=>'Save'}
View
2 views/index.haml
@@ -13,4 +13,4 @@
.span8
%form{:method=>'POST',:action=>"/pres/#{pres.id}"}
%input{:type=>'hidden',:name=>'_method',:value=>'delete'}
- %input{:type=>'submit',:value=>'Delete',:class=>'right'}
+ %input.btn{:type=>'submit',:value=>'Delete',:class=>'right'}
View
4 views/layout.haml
@@ -9,9 +9,7 @@
.topbar
.topbar-inner
.container
- %h1
- %a{:href=>"/"} Deck The Halls
- %small Sinatra Presentation Software
+ %a.brand{:href=>"/"} Deck The Halls
.pusher
.container
= yield
View
2 views/new_slide.haml
@@ -2,4 +2,4 @@
%form{:action=>'/pres/slide/new', :method => 'POST'}
%input{:type=>'hidden', :name=>'pres', :value=>params[:id]}
%textarea{:name=>'slide[content]',:cols=>'200',:rows=>'8'}
- %input{:type=>'submit',:value=>'Save'}
+ %input.btn{:type=>'submit',:value=>'Save'}
View
4 views/presentation.haml
@@ -9,10 +9,10 @@
%pre.box=h slide.content
.span3
%form{:method=>'GET',:action=>"/pres/slide/#{slide.id}",:class=>'right'}
- %input{:type=>'submit',:value=>'Edit'}
+ %input.btn{:type=>'submit',:value=>'Edit'}
.span3
%form{:method=>'POST',:action=>"/pres/slide/#{slide.id}",:class=>'right'}
%input{:type=>'hidden',:name=>'_method',:value=>'delete'}
- %input{:type=>'submit',:value=>'Delete'}
+ %input.btn{:type=>'submit',:value=>'Delete'}
%p
%a{:href=>"/pres/slide/new/#{@presentation.id}"} New Slide

0 comments on commit 81a8e43

Please sign in to comment.
Something went wrong with that request. Please try again.