Guest User

Untitled

a guest
Apr 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. # controllers/entries.rb
  2.  
  3. get '/' do
  4. @entries = Post.all
  5.  
  6. erb :index
  7. end
  8.  
  9. get '/add' do
  10. erb :add
  11. end
  12.  
  13. post '/add' do
  14. Post.find_or_create :title => params[:title], :body => params[:body]
  15.  
  16. redirect "/"
  17. end
  18.  
  19. get '/delete/?' do
  20. if params[:id]
  21. link = Link.find :id => params[:id]
  22.  
  23. if link
  24. link.destroy
  25. end
  26. end
  27.  
  28. redirect "/"
  29. end
Add Comment
Please, Sign In to add comment