Before_Filter question

Guyz,

I am having a question for you..
Scenario is i am using before_filter in controller ABC to check that
wheather user is administrator or not .. and if not then it can show
user only one page to user .. did it like this..
before_filter :authorize_admin, :except => :def

Now i want a condition that if the user is not admin but if he is a
tailor then he can see two pages as well def and xyz ..

The value of :except can be an array of values. Or you may be in a
case where you just need to add that logic to authorize_admin.

Fred

Hemant Bhargava wrote:

Thats correct that :except can be an array of values but if gave them
user can also see access the pages .. even if he is neither a admin nor
tailor ..
you mean to say that i have to do in this way ..
before_filter :authorize_admin, :except => [:def, :xyz]

Take a look at role_requirement. It should give you some ideas on how to
implement what you want, or you might be able to just use it as is:

http://github.com/timcharper/role_requirement

before_filter :authorize_admin, :except => [:def, :xyz]
before_filter :authorize_tailer, :only => [:def, :xyz] # if you have a method authorize_tailer

Thanks,
Abhinav

Not working .. In this case .. authorize_admin starts works ..
Listen my case is if user is admin then show him all pages like :abc and
:def and :xyz and if user is a simple user then show him only :abc and
if user is an tailor then show him two pages :abc and :def ..
All pages can be accessed by admin only ..

Sounds like you might need to make your authorize filter a little
smarter. The plugin Robert pointed out may do all you need or might
provide suitable inspiration.

Fred