Passing parameters to before_filter methods


#1

I have a method that checks for a given role. I want to write
something in my controllers like

before_filter :check_roles('admin')

Which will ensure the current user has the admin role. Is it possible
to pass parameters in this way?

Ian


#2

Hi Ian, I do this:

def Controller < ActionController::Base
before_filter { |c| c.role_required ‘admin’ }

def role_required(role)

end
end

cheers,
Gerret


#3

Gerret

Thanks very much for that. Think it would have taken me a while to
figure that one out!

Ian