Securing a layered Rails model

I need to do the following in Rails to mirror a desktop application:

The user and the department "own" the record, if you don't own the record at the user or office level, you are in the public world.

user reads, writes, deletes model record office reads / writes / deletes model record other or public gets read / write / delete to model record

eg.

UserA owns a read / write / delete model OfficeA owns a read / write model other / public read

I was wondering if a plugin / gem exists to provide this functionality?

+2


a source to share


3 answers


You need an authorization framework like cancan or declarative_authorization for this.



+3


a source


Nice if somewhat old plugin overview here: http://steffenbartsch.com/blog/2008/08/rails-authorization-plugins/ (last updated 2009)



It sounds like you want it to work at the model level. So select "yes" in the "M" column.

0


a source


I recommend using Grant . It is an easy-to-use, albeit rather bare, model-level security model. I'll describe in more detail in this answer .

0


a source







All Articles