I’ve been mentoring students for the firehose project for close to a year now and one thing that keeps tripping people up is how to allow for a flexible permissions system. To be clear, what I mean by permissions system is a mechanism for tracking who is associated with a particular resource and what their access rights are.
A typical blog example would include a user that has full permission on a blog post they create but can give edit and view rights to a friend they want to make small changes for example. In the same blog app we may have a comment system where we have moderators that can delete a comment if they find it in-appropriate. Depending on your app you may describe more complex relationships. But for now let’s take this case and look at how you might model that domain in Ruby On Rails.
The User Model
The primary motivation for writing this article is to remind myself how to set up some of the more complex relationships in rails and also to inform others who might be searching the interwebs for the same type of thing. If you are reading this post, hopefully you found it useful. Comments or questions always welcome. Thanks for reading.