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 .. :) -- Posted via http://www.ruby-forum.com/.
On Sep 15, 1:18 pm, Hemant Bhargava <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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> Hope you people got it right.. How can i came out from this dillema .. > :) > -- > Posted viahttp://www.ruby-forum.com/.
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 Cheung wrote:> On Sep 15, 1:18�pm, Hemant Bhargava <rails-mailing-l...@andreas-s.net> > 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-- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.
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 Bhargava < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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] > > > Frederick Cheung wrote: > > On Sep 15, 1:18�pm, Hemant Bhargava <rails-mailing-l...@andreas-s.net> > > 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 > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Saxena 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 Bhargava <-- Posted via http://www.ruby-forum.com/.
On Sep 15, 3:37 pm, Hemant Bhargava <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> Hope u people now got it right.. > > Abhinav Saxena 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 Bhargava < > > -- > Posted viahttp://www.ruby-forum.com/.