Limiting User access

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!

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