Guest User

Untitled

a guest
Jun 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. ## controller
  2. class PagesController < ResourceController::Base
  3.  
  4. update.response do |wants|
  5. wants.html { redirect_to root_url }
  6. end
  7.  
  8. def home
  9. @page = Page.find_by_title("home")
  10. end
  11.  
  12. def details
  13. @page = Page.find_by_title("details")
  14. end
  15.  
  16. def details2
  17. @page = Page.find_by_title("details2")
  18. end
  19.  
  20. end
  21.  
  22. ## view
  23. - form_for(@page, :url => object_url, :html => { :method => :put }) do |f|
  24. %p
  25. = f.text_area :text
  26. %p
  27. = f.submit "submit"
  28.  
  29. ## routes
  30. ActionController::Routing::Routes.draw do |map|
  31. map.login "login", :controller => "user_sessions", :action => "new"
  32. map.logout "logout", :controller => "user_sessions", :action => "destroy"
  33.  
  34. map.resources :user_sessions
  35. map.resources :users
  36.  
  37. map.details '/', :controller => 'pages', :action => 'home'
  38. map.details '/details', :controller => 'pages', :action => 'details'
  39. map.details2 '/details2', :controller => 'pages', :action => 'details2'
  40.  
  41. map.root :controller => "pages", :action => "home"
  42.  
  43. map.resources :pages
  44. end
Add Comment
Please, Sign In to add comment