Most applications that support login and authentication in their system also have some type of roles. That is, administrators, users, contributers perhaps, and so on. You get the idea.
One of the nicest things about the Rails ecosystem is the available gems that make certain pieces of a functionality trivial to include in an application.
If you’re looking for a solid role and authorization utility, then check out Ryan Bates’ CanCan gem:
CanCan is an authorization library for Ruby on Rails which restricts what resources a given user is allowed to access. All permissions are defined in a single location (the Ability class) and not duplicated across controllers, views, and database queries.
I’ve used it in a couple of recent projects and am a big fan.
It’s easy to get started, too. In Rails 3, add the gem to your Gemfile:
[cc lang=”text”]
gem “cancan”
[/cc]
Run Bundler:
[cc lang=”text”]
bundle install
[/cc]
Done and done!
For more information, check out the project on GitHub.
Speak your mind...