Recently I released an example application and tutorial showing how to use the Pundit gem for authorization. Pundit is great, but often it’s not needed. Many developers don’t realize that simple role-based authorization can be added to a Rails application with just a few lines of code.
I’ve released a new example application showing how to implement simple role-based authorization:
It’s available as a choice on the menu for Rails Composer, when you generate a starter application.
I’ve written an in-depth article comparing simple role-based authorization, Pundit, and the popular CanCan gem:
I’ve completed a new Role-Based Authorization Tutorial.
RailsApps subscribers are getting tutorials every month:
- September - Role-Based Authorization Tutorial
- August - OmniAuth Tutorial
- July - Rails Signup Download Tutorial
- June - Pundit Quickstart Guide
- May - Devise Quickstart Guide
- April - RSpec Quickstart Guide
- April - Learn Ruby on Rails for Rails 4.1
- March - Bootstrap and Foundation Guides
You can join RailsApps to get the tutorials and support the project.
The new tutorial covers role-based authorization, showing how to use the Active Record enum feature in Rails 4.1 to add a role attribute to a User model. You can set up roles for administrators, users with free or premium plans, or any other system of privileges. The tutorial shows how you can set up simple role-based authorization without any extra gems. For more complex applications, see the Pundit Quickstart Guide.
I appreciate the on-going support from RailsApps subscribers. If you like the articles, the tutorials, the example applications, or Rails Composer, please subscribe to support the RailsApps project.