Chapter 8. Fine-grained access control

This chapter covers

  • Implementing authorization using the Pundit gem
  • Writing a custom RSpec matcher
  • Enforcing authorization for future-proofing your code
  • Building a completely custom form for managing a user’s roles

At the end of chapter 7, you learned a basic form of authorization based on a Boolean field called admin on the users table. If this field is set to true, the user is an admin user, and can therefore access the create/destroy functions of the Project resource, as well as an admin namespace where they can perform CRUD on the User resource.

In this chapter, you’ll expand on authorization options by implementing a broader authorization system using a Role model. The records for this model’s ...

Get Rails 4 in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.