On Mar 5, 11:46 pm, Shuaib85 <[email protected]> wrote:
> basically, I made my own user access level. In one case, the admin and
> the client can delete their posts. so I do not want to rewrite the
> methods in different name
> in my code i have something like this
>
> before_filter :login_required, :only => [:delete, :edit, ....]
> before_filter :admin_required, :only => [:delete, :edit, ....]
>
> some other methods can only be implemented by admin
>
> so when I am logged in as client I cannot edit the post because i need
> to be admin as well, so is there a way to stop the before filter if
> one of them satisfied the condition
No - the only way the filter chain stops is if you redirect or render
(and then the action is not executed). The obvious solution would be
to make login_required pass if the user is an admin, then in the
example you gave you would only need
before_filter :login_required, :only => [:delete, :edit, ....]
Fred
>
> thanks
>
> On Mar 6, 1:35 am, Frederick Cheung <[email protected]>
> wrote:
>
> > On Mar 5, 11:26 pm, Shuaib85 <[email protected]> wrote:
>
> > > what i want to do is to implement one of the actions, if the first
> > > failed, then go to the second
>
> > > when i use
> > > before_filter :action1
> > > before_filter :action2
>
> > > each method will run them, my case is that i want to check if one of
> > > them is true and not both
>
> > sounds like you just want one filter that checks these 2 things.
>
> > Fred
>
> > > any idea?
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---