Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. #model
  3. def accesscheck
  4. user.permissions.find(:conditions=>["action=#{action} and controller=#{controller}"])
  5. end
  6.  
  7. #controller
  8. def getperms
  9. if user = session[:user_id]==nil
  10. flash[:notice]="please log in"
  11. redirect_to(:controller=>"login", :action=>"login")
  12. else
  13. user = User.find(session['user_id'])
  14. if user && user.accesscheck
  15. render(:controller, :action)
  16. else
  17. redirect_to :action=>'deny_access'
  18. end
  19. end
  20. end
  21.  
  22. # log
  23. Parameters: {"action"=>"index", "controller"=>"admin"}
  24. SELECT * FROM users WHERE (users.id = 4) LIMIT 1[0m
  25.  
  26.  
  27. ActiveRecord::RecordNotFound (Couldn't find User without an ID):
Add Comment
Please, Sign In to add comment