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 …

Hope you people got it right… How can i came out from this dillema …
:slight_smile:

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]

Frederick C. wrote:

On Sep 15, 1:18�pm, Hemant B. [email protected]
wrote:

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

On Sep 15, 1:18 pm, Hemant B. [email protected]
wrote:

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 B. 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

अभिनव
http://twitter.com/abhinav

On Tue, Sep 15, 2009 at 6:07 PM, Hemant B. <

On Sep 15, 3:37Â pm, Hemant B. [email protected]
wrote:

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

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 …
Hope u people now got it right…

Abhinav S. wrote:

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

Thanks,
Abhinav

अभिनव
http://twitter.com/abhinav

On Tue, Sep 15, 2009 at 6:07 PM, Hemant B. <

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs