# Canceling execution of parent method

**URL:** <https://www.ruby-forum.com/t/canceling-execution-of-parent-method/122345>\
**Category:** Rails\
**Created:** [December 6, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/canceling-execution-of-parent-method/122345 "2007-12-06T20:37:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawgaping](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@jawgaping](https://www.ruby-forum.com/u/jawgaping)\
**Post date:** [December 6, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/canceling-execution-of-parent-method/122345/1 "2007-12-06T20:37:12Z")

</div>

I’m trying to write sort of a short-and-sweet authentication  
permissions system. As it is right now, I know how I think I want it  
to work but I’m having trouble making it escape the controller action  
that was running if validation fails.

Controller in some action:  
if belongs\_to\_current\_user?(@article)  
# User must have permission to edit their own article  
permission\_required(“article”, “edit”)  
else  
# User must have permission to edit other’s articles  
permission\_required(“article”, “edit-a”)  
end

Application controller:

# Denies access to unauthorized users.

def permission\_required(cont, code)  
unless permission?(cont, code)  
flash[:warning] = “You don’t have the permission required for  
access to this function”  
redirect\_to home\_url  
return false  
end  
end

The “return false” I have there, I want it cancel processing from the  
action in my controller but it only cancels processing from the rest  
of the permission\_required method.

I’m at a loss as to how to put code safely after calling  
permission\_required in my controller, without worrying about it  
getting executed anyway after the user is redirected.
