Guest User

Untitled

a guest
Jul 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. ## this is routes.rb I get the error ROUTING ERRROR No route matches "/" with {:method=>:get}
  2.  
  3. ActionController::Routing::Routes.draw do |map|
  4.  
  5. map.resources :users
  6. map.login "login", :controller => "user_sessions", :action => "new"
  7. map.logout "logout", :controller => "user_sessions", :action => "destroy"
  8. map.resources :user_sessions
  9.  
  10. # Sample of regular route:
  11. # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  12. # Keep in mind you can assign values other than :controller and :action
  13.  
  14. # Sample of named route:
  15. # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  16. # This route can be invoked with purchase_url(:id => product.id)
  17.  
  18. # Sample resource route (maps HTTP verbs to controller actions automatically):
  19. # map.resources :products
  20.  
  21. # Sample resource route with options:
  22. # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
  23.  
  24. # Sample resource route with sub-resources:
  25. # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  26.  
  27. # Sample resource route with more complex sub-resources
  28. # map.resources :products do |products|
  29. # products.resources :comments
  30. # products.resources :sales, :collection => { :recent => :get }
  31. # end
  32.  
  33. # Sample resource route within a namespace:
  34. # map.namespace :admin do |admin|
  35. # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  36. # admin.resources :products
  37. # end
  38.  
  39. # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  40. # map.root :controller => "welcome"
  41.  
  42. # See how all your routes lay out with "rake routes"
  43.  
  44. # Install the default routes as the lowest priority.
  45. # Note: These default routes make all actions in every controller accessible via GET requests. You should
  46. # consider removing the them or commenting them out if you're using named routes and resources.
  47. #map.resources :posts
  48.  
  49. map.resources :posts, :has_many => :comments
  50. map.connect ':controller/:action/:id'
  51. map.connect ':controller/:action/:id.:format'
  52. end
  53.  
  54. ## this is my users_controller.rb
  55. lass UsersController < ApplicationController
  56.  
  57. def new
  58. @user = User.new
  59. end
  60.  
  61. def create
  62. @user = User.new(params[:user])
  63. if @user.save
  64. flash[:notice] = "You've successfully registered a new account.."
  65. redirect_to root_url
  66. else
  67. render :action => 'new'
  68. end
  69. end
  70.  
  71. def edit
  72. @user = current_user
  73. end
  74.  
  75. def update
  76. @user = current_user
  77. if @user.update_attributes(params[:user])
  78. flash[:notice] = "Successfully updated profile."
  79. redirect_to root_url
  80. else
  81. render :action => 'edit'
  82. end
  83. end
  84. end
  85.  
  86. ## this is my application_controller.rb
  87. class ApplicationController < ActionController::Base
  88. helper :all
  89. protect_from_forgery
  90. filter_parameter_logging :password
  91. #see actioncontroller::Base for more details
  92. helper_method :current_user
  93.  
  94. private
  95.  
  96. def current_user_session
  97. return @current_user_session if defined?(@current_user_session)
  98. @current_user_session = UserSession.find
  99. end
  100.  
  101. def current_user
  102. return @current_user if defined?(@current_user)
  103. @current_user = current_user_session && current_user_session.record
  104. end
  105. end
Add Comment
Please, Sign In to add comment