Assuming I have the user id in a controller, is there some sort of procedure to prevent a user from accessing specific pages and redirecting them to an appropriate spot? For instance a user is not an admin but is trying to access an admin page - is there a built in function that would allow a redirect? I know I can do it on a function by function basis in each controller but was looking for a before_XXXX type of event. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Controllers have "filters" that run before every action, so you probably want to use something like: class AdminController < ApplicationController before_filter :authorized, :except => :login private def authorized redirect_to :action => "login" if @username!=''Bill'' end end http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---