# \[ANN\] GateKeeper, Model Level Permissions Management

**URL:** <https://www.ruby-forum.com/t/ann-gatekeeper-model-level-permissions-management/131170>\
**Category:** Rails\
**Created:** [March 6, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/ann-gatekeeper-model-level-permissions-management/131170 "2008-03-06T17:13:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [March 6, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/ann-gatekeeper-model-level-permissions-management/131170/1 "2008-03-06T17:13:38Z")

</div>

I’m pleased to announce the official release of “GateKeeper”.

GateKeeper is a Rails plugin that provides easy to use methods to  
declare access permissions to instances of ActiveRecord classes at the  
model level. Permissions may be based on either a user’s roles (such as  
Admin, Moderator, etc) or on associations with other models.

In most simple and straight forward Rails projects, scoping your finds  
through has\_many associations is probably sufficient for ensuring that  
users can’t get at data they aren’t supposed to. For example, a show  
action might simply call “@note = User.current.notes.find(params[:id])”  
to ensure that the current user owns the note they’re trying to read, or  
it won’t even find it.

However, things quickly get more difficult when users need limited  
access to other user’s objects based on different roles (such as Admin,  
Moderator, Premium Subscriber, Employee of the Month, etc), or based on  
their relationship with the object’s owner (such as Owner, Supervisor of  
the Owner, etc). You might want to allow variety of people to read  
certain objects based on a variety of different roles and relationships,  
and only allow a subset of those people to update or destroy the same  
objects.

GateKeeper makes this absurdly easy to setup and maintain by allowing  
you to simply make declarations right in your model like…

createable\_by\_my\_author  
crudable\_by\_admin  
readable\_by\_premium\_member :if =\> :published?  
updateable\_by\_boss\_of\_my\_author :unless =\> lambda {|article|  
article.draft\_number \< 3 }  
readable\_as\_my\_parent

If a user on your site tries to perform an action on an instance of any  
ActiveRecord model, and permission to perform that action hasn’t been  
explicitly granted to that user via a declaration like the samples  
above, then the action is canceled and an error is raised.

GateKeeper also provides an option to do permission scoping on finds,  
automatically removing records from arrays returned by ActiveRecord  
finders that the current user doesn’t have permission to read. This is  
disabled by default and a permission error is raised if a finder returns  
an object the user doesn’t have permisison to read.

More Info Here: [http://5valleys.com/posts/show/34](http://5valleys.com/posts/show/34)  
Online Documentation/Installation Instructions Here:  
[http://gatekeeper.rubyforge.org/](http://gatekeeper.rubyforge.org/)

Feedback and Questions strongly encouraged.

–  
[http://www.5valleys.com/](http://www.5valleys.com/)  
[http://www.workingwithrails.com/person/8078](http://www.workingwithrails.com/person/8078)

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [March 7, 2008, 9:26am UTC](https://www.ruby-forum.com/t/ann-gatekeeper-model-level-permissions-management/131170/2 "2008-03-07T09:26:37Z")

</div>

I put gate\_keeper folder to vendor directory…And restarted IDE(Eclipse)  
and I get an error

private method `find’ called for ServiceDeskStatus:Class

Here ServiceDeskStatus is one of my Activeecord class.

The error occured at view  
select(“sd\_ticket”, “service\_desk\_status\_id”,  
ServiceDeskStatus.find(:all).collect {|p| [p.name, p.id] },options  
={:prompt =\> “\<\< Select any \>\>”})

What would be the cause for this?I am using rails 1.2.5 and ruby 1.8.6

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![jonlog](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jonlog](https://www.ruby-forum.com/u/jonlog)\
**Post date:** [March 7, 2008, 5:48pm UTC](https://www.ruby-forum.com/t/ann-gatekeeper-model-level-permissions-management/131170/3 "2008-03-07T17:48:31Z")

</div>

Sijo Kg wrote:

> ={:prompt =\> “\<\< Select any \>\>”})
> 
> What would be the cause for this?I am using rails 1.2.5 and ruby 1.8.6
> 
> Thanks in advance  
> Sijo

Hmmm… Well, for starters, it probably would have been good of me to  
mention that GateKeeper was built for Rails 2.0.2 and I haven’t tested  
it on versions prior to that. So, it might just not be compatible.  
Based, on what you gave above, that’s my strong suspicion. I’ll add a  
comment to the online docs to warn people about that and hopefully save  
somebody a headache or two.

–  
[http://www.5valleys.com/](http://www.5valleys.com/)  
[http://www.workingwithrails.com/person/8078](http://www.workingwithrails.com/person/8078)
