Verbose Logging

software development with some really amazing hair

14 Jul 09

08:00 AM MDT

Posted in Programming

role_on: Really Simple Roles (for Rails)

I looked at a few role systems for Rails, but never found what I wanted. They were all object based systems, never just “allow a user with this role to do this action”. Either that or I never found the systems that did that, or totally missed the docs on how to configure those systems to do what I wanted. Well, actually acl9 seemed to do that, but whatever.

So I made role_on

The instructions are on Github, so I won’t repeat them here, but it’s pretty straight forward. You control your roles yourself (which are just habtm between User, and identified by a string), and this just allows you to say something like this in your controller:

Can't see this Gist? View it on Github!

It also add a method on the User class to check roles, so you can do something like this in views:

if current_user.has_role?(:amin) # do stuff...

Enjoy.

Share/Bookmark

blog comments powered by Disqus