# ACL System restrict\_to

**URL:** <https://www.ruby-forum.com/t/acl-system-restrict-to/117656>\
**Category:** Rails\
**Created:** [October 18, 2007, 11:48pm UTC](https://www.ruby-forum.com/t/acl-system-restrict-to/117656 "2007-10-18T23:48:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [October 18, 2007, 11:48pm UTC](https://www.ruby-forum.com/t/acl-system-restrict-to/117656/1 "2007-10-18T23:48:50Z")

</div>

Does the restrict\_to method only work in the views for some reason? I  
have tried it in the controller and i get the “undefined local variable  
or method `restrict\_to’ for Admin::SurveysController:Class” Ive even  
copied the code from the access\_control.rb in the plugin to the  
application\_helper but it still keeps giving the same error.

def restrict\_to(logicstring, context = {})  
return false if current\_user.nil?  
result = ‘’  
if permit?(logicstring, context)  
result = yield if block\_given?  
end  
result  
end

???

JB

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [April 16, 2008, 11:06pm UTC](https://www.ruby-forum.com/t/acl-system-restrict-to/117656/2 "2008-04-16T23:06:01Z")

</div>

It seems that restrict\_to only works in the views, but according to  
the readme, it is meant to work in the controller.

i don’t get any errors thrown, but it doesn’t seem to work.

On Oct 18 2007, 4:48 pm, John B. \<rails-mailing-l…@andreas-
