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
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
Hi Ian, I do this:
def Controller < ActionController::Base
before_filter { |c| c.role_required ‘admin’ }
def role_required(role)
…
end
end
cheers,
Gerret
Gerret
Thanks very much for that. Think it would have taken me a while to
figure that one out!
Ian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs