code_junkie

Custom Ruby Routes in Model

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. ## Sessions Controller
  2. class SessionController < ApplicationController
  3. def create
  4. session[:password] = params[:password]
  5. flash[:notice] = "Successfully Logged In"
  6. redirect_to :controller => 'brokers', :action => 'index'
  7. end
  8.  
  9. def destroy
  10. reset_session
  11. flash[:notice] = "Successfully Logged Out"
  12. redirect_to login_path
  13. end
  14. end
  15.  
  16. ## Routes
  17. ActionController::Routing::Routes.draw do |map|
  18. map.resources :brokers, :session
  19. map.login 'login', :controller => 'session', :action => 'create'
  20. map.logout 'logout', :controller => 'session', :action => 'destroy'
  21. map.connect ':controller/:action/:id'
  22. map.connect ':controller/:action/:id.:format'
  23. end
Add Comment
Please, Sign In to add comment